Inheritance: MonoBehaviour
示例#1
0
		/// <summary>Constructs a Button from a stock.</summary>
		/// <param name="Name">Name of the stock.</param>
		/// <param name="Label">Label to display.</param>
		/// <param name="Large"><b>true</b> if the image should be large, <b>false</b> otherwise.</param>
		public static ToggleButton FromStockIcon (string Name, string Label, bool Large)
		{
			Image img = new Image (Name, Large ? IconSize.LargeToolbar : IconSize.SmallToolbar);
			ToggleButton btn = new ToggleButton (img, Label);
			if(!Large) btn.ImagePosition = PositionType.Left;
			return btn;
		}
示例#2
0
 protected override void NativeDispose()
 {
     base.NativeDispose ();
     _toggleButton = null;
     _caption = null;
     _subCaption = null;
 }
        public void Initialise(string[] milestoneTexts, string[] milestoneNumbers)
        {
            //add milestone buttons
            milestoneButtons = new ToggleButton[milestoneTexts.Length];
            for (int iMilestone = 0; iMilestone < milestoneTexts.Length; iMilestone++)
            {
                ToggleButton milestoneButton = new ToggleButton();
                milestoneButton.Template = (ControlTemplate)FindResource("MilestoneControlTemplate");
                milestoneButton.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);

                uniformGrid.Children.Add(milestoneButton);

                bool ok = milestoneButton.ApplyTemplate();
                Grid grid = (Grid)milestoneButton.Template.FindName("grid2", milestoneButton);

                //set milestone number
                TextBlock numberTextBlock = (TextBlock)grid.FindName("number");
                numberTextBlock.Text = milestoneNumbers[iMilestone];

                //set milestone description
                TextBlock descriptionTextBlock = (TextBlock)grid.FindName("description");
                descriptionTextBlock.Text = (string)milestoneTexts[iMilestone];

                milestoneButton.PreviewMouseDown += new MouseButtonEventHandler(milestoneButton_PreviewMouseDown);

                milestoneButtons[iMilestone] = milestoneButton;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimplyMobile.Plugins.StockView.Android.StockView"/> class.
        /// </summary>
        /// <param name="context">Context.</param>
        public StockViewCell (Context context) : base(context)
        {
            this.Orientation = Orientation.Vertical;

            textName = new TextView (this.Context);
            this.AddView (textName);

            textLast = new TextView (this.Context);
            this.AddView (textLast);

            this.toggleUpdate = new ToggleButton (this.Context) 
            {
                Text = "Click to update",
                TextOff = "Click to update",
                TextOn = "Updating..."
            };

            this.AddView (this.toggleUpdate);

            this.toggleUpdate.Click += async (sender, e) => 
            {
                if (this.toggleUpdate.Checked)
                {
                    await StockViewModel.StockModel.RefreshOrAdd(this.stockQuote.Symbol);
                    this.toggleUpdate.Checked = false;
                }
            };
        }
示例#5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Zone);

            id = Intent.GetIntExtra("Id", 0);
            uri = new Uri(Intent.GetStringExtra("Uri"));

            timer = new Timer();
            timer.Interval = 5000;
            timer.Elapsed += timer_Elapsed;

            powerButton = FindViewById<ToggleButton>(Resource.Id.powerButton);
            powerButton.Click += powerButton_Click;

            volumeSeekBar = FindViewById<SeekBar>(Resource.Id.volumeSeekBar);
            volumeSeekBar.ProgressChanged += volumeSeekBar_ProgressChanged;

            sourceSpinner = FindViewById<Spinner>(Resource.Id.sourceSpinner);
            sourceSpinner.Adapter = new ArrayAdapter<string>(this, global::Android.Resource.Layout.SimpleSpinnerDropDownItem, AUDIO_SOURCES);
            sourceSpinner.ItemSelected += sourceSpinner_ItemSelected;

            // schedule load
            Task.Run(async () => await Load());
        }
        public override View GetView(Context context, View convertView, ViewGroup parent)
        {
            View toggleButtonView;
            View view = DroidResources.LoadBooleanElementLayout(context, convertView, parent, LayoutId, out _caption, out _subCaption, out toggleButtonView);

            if (view != null)
            {
                _caption.Text = Caption;
                _toggleButton = (ToggleButton)toggleButtonView;
                _toggleButton.SetOnCheckedChangeListener(null);
                _toggleButton.Checked = Value;
                _toggleButton.SetOnCheckedChangeListener(this);

                if (TextOff != null)
                {
                    _toggleButton.TextOff = TextOff;
                    if (!Value)
                        _toggleButton.Text = TextOff;
                }

                if (TextOn != null)
                {
                    _toggleButton.TextOn = TextOn;
                    if (Value)
                        _toggleButton.Text = TextOn;
                }
            }
            return view;
        }
示例#7
0
        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("EqualizerPresetsActivity - OnCreate");
            base.OnCreate(bundle);

            _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            SetContentView(Resource.Layout.EqualizerPresets);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            _seekBarVolume = FindViewById<SeekBar>(Resource.Id.equalizerPresets_seekBarVolume);
            _seekBarVolume.ProgressChanged += (sender, args) => OnSetVolume(1);

            _btnBypass = FindViewById<ToggleButton>(Resource.Id.equalizerPresets_btnBypass);
            _btnBypass.Click += (sender, args) => OnBypassEqualizer();

            _outputMeter = FindViewById<OutputMeterView>(Resource.Id.equalizerPresets_outputMeterView);

            _listView = FindViewById<ListView>(Resource.Id.equalizerPresets_listView);
            _listAdapter = new EqualizerPresetsListAdapter(this, _listView, new List<EQPreset>());
            _listView.SetAdapter(_listAdapter);
            _listView.ItemClick += ListViewOnItemClick;
            _listView.ItemLongClick += ListViewOnItemLongClick;

            // Save the source activity type for later (for providing Up navigation)
            _sourceActivityType = Intent.GetStringExtra("sourceActivity");

            // Since the onViewReady action could not be added to an intent, tell the NavMgr the view is ready
            //((AndroidNavigationManager)_navigationManager).SetEqualizerPresetsActivityInstance(this);
            _navigationManager.BindEqualizerPresetsView(null, this);
        }
示例#8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.Hide();
            SetContentView(Resource.Layout.Main);
            cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
            player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
            toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                StartActivity(typeof(Login));
            };


            toggleMusic.Click += (o, s) =>

            {
                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);

                }
                else
                {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };


        }
示例#9
0
        /// <summary>Default constructor.</summary>
        public Gallery()
        {
            this.SetFlag (WidgetFlags.NoWindow);

            this.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            this.tiles = new List<Tile> ();
            this.selectedTiles = new List<Tile> ();

            this.defaultTilesPerRow = 3;
            this.firstDisplayedTileIndex = 0;
            this.lastDisplayedTileIndex = -1;
            this.multiSelect = false;

            this.tileHeight = 56;
            this.tileWidth = 72;
            this.tileSpacing = 0;
            this.BorderWidth = 2;

            this.up = new Button ("\u25B2");
            this.up.Parent = this;
            this.up.Padding = 0;
            this.up.Clicked += up_Clicked;

            this.down = new Button ("\u25BC");
            this.down.Parent = this;
            this.down.Padding = 0;
            this.down.Clicked += down_Clicked;

            this.expand = new ToggleButton ("\u2193");
            this.expand.Parent = this;
            this.expand.Padding = 0;
            this.expand.ValueChanged += expand_ValueChanged;
        }
示例#10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.HomeScreen, container, false);
            infoButton = view.FindViewById<Button>(Resource.Id.infoButton);
            player = MediaPlayer.Create(view.Context, Resource.Raw.avril_14th);
            toggleMusic = view.FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            cover = view.FindViewById<RelativeLayout>(Resource.Id.titleScreen);

            Xamarin.Insights.Initialize(XamarinInsights.ApiKey, view.Context);
            CurrentPlatform.Init();

            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                facebookLogin.Invoke(this, new LoginEventArgs());
            };

            toggleMusic.Click += (o, s) => {

                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
                }
                else {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };

            return view;
        }
      protected override View OnCreateDialogView()
      {
         
         LayoutInflater inflator = LayoutInflater.FromContext(this.Context);
         View dialog = inflator.Inflate(Resource.Layout.opencl_preference, null);

         _openCLToggleButton = dialog.FindViewById<ToggleButton>(Resource.Id.opencl_preference_toggleButton);

         AppPreference preference = new AppPreference();
         _openCLToggleButton.Checked = preference.UseOpenCL;

         _openCLToggleButton.CheckedChange += (sender, args) =>
         {
            bool isChecked = args.IsChecked;

            if (isChecked && !CvInvoke.HaveOpenCL)
            {
               _openCLToggleButton.Checked = false;
               Toast.MakeText(Context, "No OpenCL compatible device found.", ToastLength.Long).Show();
               isChecked = false;
            }

            preference.UseOpenCL = isChecked;
         };

         return dialog;
      }
		public override bool OnCreateOptionsMenu (Android.Views.IMenu menu)
		{
			MenuInflater.Inflate (Resource.Menu.main_screen, menu);

			_addAlarmMenuButton = menu.FindItem (Resource.Id.add_alarm);
			_acceptMenuButton = menu.FindItem (Resource.Id.accept);
			_alarmNameMenuItem = menu.FindItem (Resource.Id.alarm_name);
			_deleteAlarmMenuItem = menu.FindItem (Resource.Id.delete);
			_disableAlarmMenuItem = menu.FindItem (Resource.Id.switch_button);
			_alarmRadiusMenuItem = menu.FindItem (Resource.Id.alarm_radius);
			_settingsMenuItem = menu.FindItem (Resource.Id.action_settings);
            
			_alarmNameEditText = MenuItemCompat.GetActionView (_alarmNameMenuItem) as EditText;
			_alarmNameEditText.Hint = Resources.GetString (Resource.String.alarm_name);
			_alarmNameEditText.SetWidth (Resources.GetDimensionPixelSize (Resource.Dimension.abc_search_view_preferred_width));

			_enableAlarmToggleButton = MenuItemCompat.GetActionView (_disableAlarmMenuItem) as ToggleButton;
			_enableAlarmToggleButton.CheckedChange += AlarmEnabledChange;

			_alarmRadiusSpinner = MenuItemCompat.GetActionView (_alarmRadiusMenuItem) as Spinner;
			var adapter = new ArrayAdapter (this, Resource.Layout.support_simple_spinner_dropdown_item, 
				              Android.Resource.Id.Text1, Constants.AlarmRadiusValues.Select (r => string.Format ("{0} m", r)).ToList ());
			adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem);
			_alarmRadiusSpinner.Adapter = adapter;
			_alarmRadiusSpinner.ItemSelected += (s, e) => RedrawAddCircle ();

			ManageMenuItemsVisibilityForMode ();

			_addAlarmMenuButton.SetVisible (_isGooglePlayServicesAvailable == ConnectionResult.Success);

			return base.OnCreateOptionsMenu (menu);
		}
 public void SetDisplayMode_Should_Update_Existing_DisplayMode()
 {
     var sut = new ToggleButton();
     var actual = ToggleButtonDisplayMode.Large;
     sut.SetDisplayMode(ToggleButtonDisplayMode.Medium);
     sut.SetDisplayMode(actual);
     Assert.AreEqual(actual.ToString(), sut.GetDisplayMode());
 }
 public void GetToggleButton_Should_Find_And_Return_Correct_ToggleButton()
 {
     var actual = new ToggleButton("MyToggleButton");
     var fake = new ToggleButton("MyToggleBUtton");
     _sut._toggleButtons.Add(fake);
     _sut._toggleButtons.Add(actual);
     Assert.AreEqual(actual, _sut.GetToggleButton("MyToggleButton"));
 }
示例#15
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Main);
			manager = (UsbManager)this.GetSystemService (Context.UsbService);
			tgConnect = FindViewById<ToggleButton>(Resource.Id.toggleButton1);
			Result = FindViewById<TextView>(Resource.Id.textView1);
			tgConnect.CheckedChange += tgConnect_HandleCheckedChange;
		}
示例#16
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Main);
			tgConnect = FindViewById<ToggleButton>(Resource.Id.toggleButton1);
			Result = FindViewById<TextView>(Resource.Id.textView1);
			tgConnect.CheckedChange += tgConnect_HandleCheckedChange;
			CheckBt();
		}
示例#17
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         //_toggleButton.Dispose();
         _toggleButton = null;
         //_caption.Dispose();
         _caption = null;
     }
 }
示例#18
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         sw.Dispose();
         sw = null;
         tv.Dispose();
         tv = null;
     }
 }
		public BoolFormatCell (Context ctxt) : base (ctxt)
		{
			isOpen = new ToggleButton (ctxt);
			isOpen.SetTextColor (Color.Rgb (51, 51, 51));
			isOpen.TextOn = "Open";
			isOpen.TextOff = "Closed";
			isOpen.Click += isOpen_Click;
			CanRenderUnLoad = false;
			this.AddView (isOpen);
		}
示例#20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            flash = new Flash(PackageManager);

            linearLayout = FindViewById<LinearLayout>(Resource.Id.lnlBackground);
            tbtInterruptor = FindViewById<ToggleButton>(Resource.Id.tbtInterruptor);
            tbtInterruptor.Click += LigaDesliga;
        }
    public void Start()
    {
        buttons = GetComponentsInChildren<ToggleButton>();
        activeButton = bellsButton;

        RefreshButtons();

        checkpointButton.OnClick += ChangeActiveButton;
        bellsButton.OnClick += ChangeActiveButton;
        tapButton.OnClick += ChangeActiveButton;
        settingsButton.OnClick += ChangeActiveButton;
    }
示例#22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetTheme (Android.Resource.Style.ThemeHoloLightNoActionBar);
            SetContentView (Resource.Layout.frmAggiungiUtente);

            txtCognome = FindViewById<EditText> (Resource.Id.txtCognome);
            txtNome = FindViewById<EditText> (Resource.Id.txtNome);
            txtNumeroTessera = FindViewById<EditText> (Resource.Id.txtNumeroTessera);
            radioTipo = FindViewById<RadioGroup> (Resource.Id.gruppoTipi);
            dataIscrizione = FindViewById<DatePicker> (Resource.Id.datePicker1);
            dataIscrizione.Init (DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,new DateChangedListener((picker, year, month, day) => {
                valutaScadenza();
            }));
            txtSaldo = FindViewById<EditText> (Resource.Id.txtSaldo);
            txtDataScadenza = FindViewById<TextView> (Resource.Id.txtScadenza);

            Button btnSalva = FindViewById<Button> (Resource.Id.btnSalva);
            Button btnAnnulla = FindViewById<Button> (Resource.Id.btnAnnulla);
            Button btnElimina = FindViewById<Button> (Resource.Id.btnElimina);
            btnScade = FindViewById<ToggleButton> (Resource.Id.btnPuoScadere);
            btnScade.Activated = puoScadere;

            btnScade.CheckedChange+= BtnScade_CheckedChange;

            btnElimina.Enabled = false;
            if (this.Intent.HasExtra("numtessera")) {
                insertMode = false;
                numtessera =  Intent.GetIntExtra ("numtessera",0).ToString();
                btnElimina.Enabled = true;
                riprendiCliente (numtessera);
            }
            btnElimina.Click += BtnElimina_Click;
            btnSalva.Click+= BtnSalva_Click;
            btnAnnulla.Click += (sender, e) => {
                funzioni.MsgBox(this,"Annullare l'inserimento (Tutti i dati non salvati andranno persi!) ?",
                    "Vegetha",
                    "SI",
                    ()=>{SetResult(Result.Ok);  Finish(); },
                    "NO",
                    ()=>{});

            };

            txtCognome.FocusChange+= txtFocusChange;
            txtNome.FocusChange += txtFocusChange;
            radioTipo.CheckedChange += (sender, e) => {
                valutaScadenza ();
            };
            radioTipo.Check( Resource.Id.radioAnnuale);
            valutaScadenza ();
        }
示例#23
0
        void ShowProxySettings ()
        {
            dialog = new Dialog (this);
            dialog.SetContentView (Resource.Layout.Proxy);
            dialog.SetTitle ("Proxy Settings"); 
            dialog.SetCancelable (true);

            dialog.CancelEvent += DialogDismissHandler;

            Button btnProxySave = (Button)dialog.FindViewById (Resource.Id.btnProxySave);
            Button btnProxyCancel = (Button)dialog.FindViewById (Resource.Id.btnProxyCancel);

            btnProxySave.Click += EnableProxy; 
            btnProxyCancel.Click += DisableProxy;
            
            proxyUsername = (EditText)dialog.FindViewById (Resource.Id.proxyUsername);
            proxyPassword = (EditText)dialog.FindViewById (Resource.Id.proxyPassword);
            proxyServer = (EditText)dialog.FindViewById (Resource.Id.proxyServer);
            proxyPort = (EditText)dialog.FindViewById (Resource.Id.proxyPort);
            
            tgProxy = (ToggleButton)dialog.FindViewById (Resource.Id.tbProxy);
            tgProxy.CheckedChange += ProxyCheckedChanged;
            tgProxy.Checked = true;

            if (proxy != null) {
                tgProxy.Checked = true;
                tvProxy.Text = SetProxyText(true);
            } else {
                tgProxy.Checked = false;

                tvProxy.Text = SetProxyText(false);
            }

            if ((proxy != null) && (!string.IsNullOrEmpty (proxy.ProxyServer))) {
                proxyServer.Text = proxy.ProxyServer;
            }
            if ((proxy != null) && (!string.IsNullOrEmpty (proxy.ProxyPort.ToString()))) {
                proxyPort.Text = proxy.ProxyPort.ToString();
            }
            if ((proxy != null) && (!string.IsNullOrEmpty (proxy.ProxyUserName))) {
                proxyUsername.Text = proxy.ProxyUserName;
            }
            if ((proxy != null) && (!string.IsNullOrEmpty (proxy.ProxyPassword))) {
                proxyPassword.Text = proxy.ProxyPassword;
            }

            dialog.Show();
        }
示例#24
0
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.ActionBar);
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.UploadsActivity);

            View header = LayoutInflater.Inflate(Resource.Layout.UploadsListHead, null);
            uploadsList = FindViewById<ListView>(Resource.Id.uploads_list);
            uploadsList.AddHeaderView(header, null, false);
            uploadsList.Adapter = new ExportedListAdapter(this, Resource.Id.uploads_list, AppData.Session.ResultsToUpload.ToArray());
            uploadsList.ItemClick += OnItemTap;

            uploadAllButton = FindViewById<ToggleButton>(Resource.Id.uploads_start);
            uploadAllButton.Click += uploadAllButton_Click;
        }
示例#25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DatePicker);

            // Assign UI Variables
            //cancelButton = FindViewById<Button>(Resource.Id.cancelButton);
            saveButton = FindViewById<Button>(Resource.Id.saveButton);
            inOutButton = FindViewById<ToggleButton>(Resource.Id.inOutButton);
            inOutButton.Checked = true;
            title = FindViewById<TextView>(Resource.Id.title);
            dateButton = FindViewById<Button>(Resource.Id.dateButton);
            timeButton = FindViewById<Button>(Resource.Id.timeButton);

            // Get current date
            date = DateTime.Today;
            hour = DateTime.Now.Hour;
            minute = DateTime.Now.Minute;

            // Display current date (this method is below)
            UpdateDisplay();

            EmployeeNumber = Intent.GetStringExtra("EmployeeNumber");
            employee = EmployeeManagement.GetInstance().Employees.Where(L => L.Number == EmployeeNumber).FirstOrDefault();

            // Add a click event handler to the buttons
            dateButton.Click += delegate {
                ShowDialog(DATE_DIALOG_ID);
            };

            timeButton.Click += delegate {
                ShowDialog(TIME_DIALOG_ID);
            };

            inOutButton.Click += delegate
            {
                UpdateDisplay();
            };
            /*
            cancelButton.Click += delegate
            {
                Finish();
            };
             */

            saveButton.Click += SaveTime_Click;
        }
示例#26
0
        public ToggleButonView(ToggleButton control, Sprite spriteOn, Sprite spriteOff)
            : base(control)
        {
            _control = control;
            _control.Invalidated += UpdateVisual;
            _control.ValueChanged += UpdateValue;
            _spriteOn = spriteOn;
            _spriteOff = spriteOff;

            _spriteOn.DrawMode = control.DrawMode;
            _spriteOff.DrawMode = control.DrawMode;
            _spriteOn.HorizontalAlignment = _spriteOff.HorizontalAlignment = HorizontalAlignment.Left;
            _spriteOn.VerticalAlignment = _spriteOff.VerticalAlignment = VerticalAlignment.Top;

            Value = control.Value;

            Size = control.Size;
        }
示例#27
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            rootView = inflater.Inflate (Resource.Layout.MainToday, container, false);

            todayDate = rootView.FindViewById<TextView> (Resource.Id.TodayDate);
            todayDay  = rootView.FindViewById<TextView> (Resource.Id.TodayDay);
            todayTime = rootView.FindViewById<TextView> (Resource.Id.TodayTime);
            historyList = rootView.FindViewById<ListView> (Resource.Id.TodayHistoryList);
            historyList.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) => {
                if(toggleAbstDetail.Checked) {	// at raw state
                    ViewModel.SelectRawTaskHistory(e.Position);
                    var taskPickerFragment = new TaskPickerFragment();
                    taskPickerFragment.Show(Activity.SupportFragmentManager, "taskPicker");
                }
            };

            toggleAbstDetail = rootView.FindViewById<ToggleButton> (Resource.Id.toggleAbstDetail);
            toggleAbstDetail.AfterTextChanged += (object sender, Android.Text.AfterTextChangedEventArgs e) => { SetAdapter(); };

            SetAdapter ();

            timer = new Timer ();
            timer.AutoReset = true;
            timer.Interval = 100;	// 100ms
            timer.Elapsed += (object sender, ElapsedEventArgs e) => {
                handler.Post(() =>
                    {
                        todayTime.Text = DateTime.Now.ToLongTimeString();
                        todayDate.Text = ViewModel.ShowDate.ToShortDateString ();
                        todayDay.Text = DateTime.Today.DayOfWeek.ToString ();
                    });
            };
            timer.Enabled = true;

            todayDate.Touch += (object sender, View.TouchEventArgs e) => {
                if(e.Event.Action == MotionEventActions.Up) {
                    var df = new HistoryDatePickerFragment(todayDate);
                    df.Show(this.FragmentManager, "historyDatePicker");
                }
            };

            return rootView;
        }
		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			View view = inflater.Inflate(Resource.Layout.EditProfileActivity, container, false);

			View toolbarLayout = view.FindViewById(Resource.Id.toolbarLayout);
			((TextView)toolbarLayout.FindViewById(Resource.Id.toolbar_titleCenter)).Text = "Edit Profile";
			ImageView toolbarImageFarLeft = (ImageView)toolbarLayout.FindViewById(Resource.Id.toolbar_imageFarLeft);
			toolbarImageFarLeft.Visibility = ViewStates.Visible;
			Drawable backArrow = Context.Resources.GetDrawable(Resource.Drawable.abc_ic_ab_back_mtrl_am_alpha);
			backArrow.SetColorFilter(Resources.GetColor(Resource.Color.tenBlue), PorterDuff.Mode.SrcAtop);
			toolbarImageFarLeft.SetImageDrawable(backArrow);
			toolbarImageFarLeft.Click += (sender, e) =>
			{
				FragmentManager.PopBackStack();
			};
			TextView toolbarTextFarRight = (TextView)toolbarLayout.FindViewById(Resource.Id.toolbar_textFarRight);
			toolbarTextFarRight.Visibility = ViewStates.Visible;
			toolbarTextFarRight.Text = "Save";
			toolbarTextFarRight.Click += (sender, e) =>
			{
				SaveButtonClicked();
			};

			UsernameLabel = view.FindViewById<TextView>(Resource.Id.usernameLabel);
			BioTextView = view.FindViewById<EditText>(Resource.Id.bioEditText);
			WebsiteTextField = view.FindViewById<EditText>(Resource.Id.websitedittext);

			PrivateToggleButton = view.FindViewById<ToggleButton>(Resource.Id.privacyToggle);
			PrivateToggleButton.CheckedChange += (sender, e) =>
			{
				newPrivacy = PrivateToggleButton.Checked;
			};

			view.FindViewById<TextView>(Resource.Id.usernameLabel).Text = Globe.SharedInstance.User.username;


			UserImageButton = view.FindViewById<WebImage>(Resource.Id.userimagebutton);

			SetPageVariables();

			return view;
		}
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_list_view_data_operations, container, false);
            this.listView = (RadListView) rootView.FindViewById(Resource.Id.listView).JavaCast<RadListView>();
            this.btnSort = (ToggleButton) rootView.FindViewById(Resource.Id.btnSort);
            this.btnSort.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                ListViewDataSourceAdapter dsa = (ListViewDataSourceAdapter) listView.GetAdapter();

                if (e.IsChecked) {
                    // Sort by price
                    dsa.AddSortDescriptor(new MySortDescriptor());
                } else {
                    dsa.ClearSortDescriptors();
                }
            };

            this.btnFilter = (ToggleButton) rootView.FindViewById(Resource.Id.btnFilter);
            this.btnFilter.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                ListViewDataSourceAdapter dsa = (ListViewDataSourceAdapter)listView.GetAdapter ();

                if (e.IsChecked) {
                    dsa.AddFilterDescriptor (new MyFilterDescriptor ());
                } else {
                    dsa.ClearFilterDescriptors ();
                }

            };

            this.btnGroup = (ToggleButton) rootView.FindViewById(Resource.Id.btnGroup);
            this.btnGroup.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                ListViewDataSourceAdapter dsa = (ListViewDataSourceAdapter) listView.GetAdapter();
                if (e.IsChecked) {
                    dsa.AddGroupDescriptor(new MyGroupDescriptor());
                } else {
                    dsa.ClearGroupDescriptors();
                }
            };

            this.listView.SetAdapter(new MyDataListViewAdapter(this.getData()));

            return rootView;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            base.SetContentView(Resource.Layout.picasso_sample_activity);
            sampleContent = FindViewById<FrameLayout>(Resource.Id.sample_content);

            ListView activityList = FindViewById<ListView>(Resource.Id.activity_list);
            PicassoSampleAdapter adapter = new PicassoSampleAdapter(this);
            activityList.Adapter = adapter;
            activityList.ItemClick += (sender, e) =>
            {
                adapter[e.Position].Launch(this);
            };

            showHide = FindViewById<ToggleButton>(Resource.Id.faux_action_bar_control);
            showHide.CheckedChange += (sender, e) =>
            {
                activityList.Visibility = e.IsChecked ? ViewStates.Visible : ViewStates.Gone;
            };
        }
示例#31
0
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.gbWebsite = (GroupBox)target;
                return;

            case 2:
                this.cmbWebsite = (ComboBox)target;
                this.cmbWebsite.SelectionChanged += new SelectionChangedEventHandler(this.cmbWebsite_SelectionChanged);
                return;

            case 3:
                this.imgInfo = (Image)target;
                return;

            case 4:
                this.lblCheckoutLink = (TextBlock)target;
                return;

            case 5:
                this.cmbCheckoutlink = (ComboBox)target;
                this.cmbCheckoutlink.SelectionChanged += new SelectionChangedEventHandler(this.cmbCheckoutlink_SelectionChanged);
                this.cmbCheckoutlink.DropDownOpened   += new EventHandler(this.cmbCheckoutlink_DropDownOpened);
                return;

            case 6:
                this.gbLogin = (GroupBox)target;
                return;

            case 7:
                this.switchLogin            = (ToggleButton)target;
                this.switchLogin.Checked   += new RoutedEventHandler(this.switchLogin_Checked);
                this.switchLogin.Unchecked += new RoutedEventHandler(this.switchLogin_Checked);
                return;

            case 8:
                this.txtUsername = (TextBox)target;
                return;

            case 9:
                this.txtPassword = (TextBox)target;
                return;

            case 10:
                this.gbTaskType = (GroupBox)target;
                return;

            case 11:
                this.rTypeDirect            = (RadioButton)target;
                this.rTypeDirect.Checked   += new RoutedEventHandler(this.rType_Checked);
                this.rTypeDirect.Unchecked += new RoutedEventHandler(this.rType_Checked);
                return;

            case 12:
                this.rTypeKeywords            = (RadioButton)target;
                this.rTypeKeywords.Checked   += new RoutedEventHandler(this.rType_Checked);
                this.rTypeKeywords.Unchecked += new RoutedEventHandler(this.rType_Checked);
                return;

            case 13:
                this.rTypeVariant            = (RadioButton)target;
                this.rTypeVariant.Checked   += new RoutedEventHandler(this.rType_Checked);
                this.rTypeVariant.Unchecked += new RoutedEventHandler(this.rType_Checked);
                return;

            case 14:
                this.txtQuantity = (TextBox)target;
                this.txtQuantity.PreviewTextInput += new TextCompositionEventHandler(this.NumberCheck);
                return;

            case 15:
                this.rowDirectlink = (StackPanel)target;
                return;

            case 0x10:
                this.lblLink = (TextBlock)target;
                return;

            case 0x11:
                this.txtLink              = (TextBox)target;
                this.txtLink.TextChanged += new TextChangedEventHandler(this.txtLink_TextChanged);
                return;

            case 0x12:
                this.lblLinkType = (TextBlock)target;
                return;

            case 0x13:
                this.rowVariant = (StackPanel)target;
                return;

            case 20:
                this.lblVariant = (TextBlock)target;
                return;

            case 0x15:
                this.txtVariant = (TextBox)target;
                return;

            case 0x16:
                this.rowPositive = (StackPanel)target;
                return;

            case 0x17:
                this.lblPositiveKws = (TextBlock)target;
                return;

            case 0x18:
                this.txtPositiveKws = (TextBox)target;
                return;

            case 0x19:
                this.rowNegative = (StackPanel)target;
                return;

            case 0x1a:
                this.lblNegativeKws = (TextBlock)target;
                return;

            case 0x1b:
                this.txtNegativeKws = (TextBox)target;
                return;

            case 0x1c:
                this.rowSearch = (StackPanel)target;
                return;

            case 0x1d:
                this.textBlock_0 = (TextBlock)target;
                return;

            case 30:
                this.switchLast25 = (ToggleButton)target;
                return;

            case 0x1f:
                this.pDeepSearch = (StackPanel)target;
                return;

            case 0x20:
                this.switchDeepSearch            = (ToggleButton)target;
                this.switchDeepSearch.Checked   += new RoutedEventHandler(this.switchDeepSearch_Checked);
                this.switchDeepSearch.Unchecked += new RoutedEventHandler(this.switchDeepSearch_Checked);
                return;

            case 0x21:
                this.lblDeepSearchLinks = (TextBlock)target;
                return;

            case 0x22:
                this.txtDeepSearchLinks = (TextBox)target;
                this.txtDeepSearchLinks.PreviewTextInput += new TextCompositionEventHandler(this.NumberCheck);
                return;

            case 0x23:
                this.gbSize = (GroupBox)target;
                return;

            case 0x24:
                this.txtColor = (TextBox)target;
                return;

            case 0x25:
                this.rColorExact = (RadioButton)target;
                return;

            case 0x26:
                this.rColorContains = (RadioButton)target;
                return;

            case 0x27:
                this.chPickRandomColorNotAvailable = (CheckBox)target;
                return;

            case 40:
                this.gbPayment = (GroupBox)target;
                return;

            case 0x29:
                this.radioButton_0            = (RadioButton)target;
                this.radioButton_0.Checked   += new RoutedEventHandler(this.Payment_checked);
                this.radioButton_0.Unchecked += new RoutedEventHandler(this.Payment_checked);
                return;

            case 0x2a:
                this.radioButton_1            = (RadioButton)target;
                this.radioButton_1.Checked   += new RoutedEventHandler(this.Payment_checked);
                this.radioButton_1.Unchecked += new RoutedEventHandler(this.Payment_checked);
                return;

            case 0x2b:
                this.cmbParentTask = (ComboBox)target;
                return;

            case 0x2c:
                this.lblOldMode = (TextBlock)target;
                return;

            case 0x2d:
                this.switchOldMode = (ToggleButton)target;
                return;
            }
            this._contentLoaded = true;
        }
示例#32
0
        public void ToggleButton_DragEnter(object sender, PointerRoutedEventArgs e)
        {
            ToggleButton button = sender as ToggleButton;

            RatingValueHover = (int)button.Tag;
        }
示例#33
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.FormWidgetsTutorial);

            Button button = FindViewById <Button> (Resource.Id.button);

            button.Click += (o, e) => {
                Toast.MakeText(this, "Beep Boop", ToastLength.Short).Show();
            };

            EditText edittext = FindViewById <EditText> (Resource.Id.edittext);

            edittext.KeyPress += (o, e) => {
                if (e.E.Action == KeyEventActions.Down && ((Keycode)e.KeyCode) == Keycode.Enter)
                {
                    Toast.MakeText(this, edittext.Text, ToastLength.Short).Show();
                }

                e.Handled = false;
            };

            CheckBox checkbox = FindViewById <CheckBox> (Resource.Id.checkbox);

            checkbox.Click += (o, e) => {
                if (checkbox.Checked)
                {
                    Toast.MakeText(this, "Selected", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(this, "Not selected", ToastLength.Short).Show();
                }
            };

            RadioButton radio_red  = FindViewById <RadioButton> (Resource.Id.radio_red);
            RadioButton radio_blue = FindViewById <RadioButton> (Resource.Id.radio_blue);

            radio_red.Click += RadioButtonClick;
            radio_red.Click += RadioButtonClick;

            ToggleButton togglebutton = FindViewById <ToggleButton> (Resource.Id.togglebutton);

            togglebutton.Click += (o, e) => {
                // Perform action on clicks
                if (togglebutton.Checked)
                {
                    Toast.MakeText(this, "Checked", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(this, "Not checked", ToastLength.Short).Show();
                }
            };

            RatingBar ratingbar = FindViewById <RatingBar> (Resource.Id.ratingbar);

            ratingbar.RatingBarChange += (o, e) => {
                Toast.MakeText(this, "New Rating: " + ratingbar.Rating.ToString(), ToastLength.Short).Show();
            };
        }
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            if (popup != null)
            {
                popup.Closed -= OnPopupClosed;
                popup.Opened -= OnPopupOpened;
            }
            _minimizedButtonContainer = e.NameScope.Find <Control>(partMinimizedButtonContainer);

            popup = e.NameScope.Find <Popup>(partPopup);
            if (popup != null)
            {
                popup.Closed += new EventHandler(OnPopupClosed);
                popup.Opened += new EventHandler(OnPopupOpened);
            }

            ToggleButton btn = e.NameScope.Find <ToggleButton>("PART_ToggleButton");

            if (btn != null)
            {
                btn.PointerReleased += Btn_PointerReleased;
            }

            btnMenu = e.NameScope.Find <ToggleButton>("toggleMenu");

            btnMenu.PointerLeave += (o, e) =>
            {
                e.Pointer.Capture(null);
            };

            btnMenu.Click += (o, e) =>
            {
                ApplyOverflowMenu();

                if (OverflowMenuItems.Count == 0)
                {
                    return;
                }

                //IsOverflowVisible = !IsOverflowVisible;
                if (btnMenu.ContextMenu.IsOpen == false)
                {
                    btnMenu.ContextMenu.Items = OverflowMenuItems;
                    btnMenu.ContextMenu.Open(this);
                }
                else
                {
                    btnMenu.ContextMenu.Close();
                }
            };

            //Border headerBorder = e.NameScope.Find<Border>("headerBorder");
            //headerBorder.DoubleTapped += (o, e) =>
            //{
            //    IsMaximized = !IsMaximized;
            //};

            e.NameScope.Find <Button>("resizeButton").Click += (o, e) =>
            {
                ResizeCommand.Execute(o);
            };

            e.NameScope.Find <Button>("closeButton").Click += (o, e) =>
            {
                CloseCommand.Execute(o);
            };

            e.NameScope.Find <Button>("toggleMinimizeButton").Click += (o, e) =>
            {
                CollapseCommand.Execute(o);
            };

            e.NameScope.Find <Button>("splitter").Click += (o, e) =>
            {
                StartDraggingCommand.Execute(o);
            };

            base.OnTemplateApplied(e);

            RaisePropertyChanged(OdcExpanderClassesProperty, null, (Classes)OdcExpanderClasses);
            ApplySections();

            //RaisePropertyChanged(IsOverflowVisibleProperty, !IsOverflowVisible, IsOverflowVisible);
        }
示例#35
0
        public ButtonSample()
        {
            Button b1 = new Button("Click me");

            b1.Clicked += delegate {
                b1.Label = "Clicked!";
            };
            PackStart(b1);

            Button b2 = new Button("Click me");

            b2.Style    = ButtonStyle.Flat;
            b2.Clicked += delegate {
                b2.Label = "Clicked!";
            };
            PackStart(b2);

            PackStart(new Button(StockIcons.ZoomIn.WithSize(22)));
            PackStart(new Button(new CustomImage().WithSize(22)));

            MenuButton mb  = new MenuButton("This is a Menu Button");
            Menu       men = new Menu();

            men.Items.Add(new MenuItem("First"));
            men.Items.Add(new MenuItem("Second"));
            men.Items.Add(new MenuItem("Third"));
            men.Items.Add(new SeparatorMenuItem());
            men.Items.Add(new CheckBoxMenuItem("Check")
            {
                Checked = true
            });
            men.Items.Add(new RadioButtonMenuItem("Radio")
            {
                Checked = true
            });
            men.Items.Add(new MenuItem("With image")
            {
                Image = Image.FromResource(typeof(App), "class.png")
            });

            mb.Menu = men;
            PackStart(mb);
            foreach (var mi in men.Items)
            {
                var cmi = mi;
                mi.Clicked += delegate {
                    mb.Label = cmi.Label + " Clicked";
                };
            }

            ToggleButton tb = new ToggleButton("Toggle me");

            PackStart(tb);

            var b = new Button("Mini button");

            b.Style = ButtonStyle.Borderless;
            PackStart(b);

            tb       = new ToggleButton("Mini toggle");
            tb.Style = ButtonStyle.Borderless;
            PackStart(tb);


            var child     = new VBox();
            var container = new MyWidget {
                Content = child
            };

            var button = new Xwt.Button("Click to add a child");

            button.Clicked += delegate {
                child.PackStart(new Xwt.Label("Child" + child.Children.Count()));
            };

            var content = new Xwt.VBox();

            content.PackStart(button);
            content.PackStart(container);

            PackStart(content);
        }
示例#36
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            v = inflater?.Inflate(Resource.Layout.Calc_AreaExpCalc, container, false);

            // Find View & Connect Event

            areaList = v.FindViewById <Spinner>(Resource.Id.CalcAreaSelector);
            areaList.ItemSelected += AreaList_ItemSelected;
            nowLevel = v.FindViewById <NumberPicker>(Resource.Id.CalcAreaExpNowLevel);
            nowLevel.ValueChanged    += LevelSelector_ValueChanged;
            targetLevel               = v.FindViewById <NumberPicker>(Resource.Id.CalcAreaExpTargetLevel);
            targetLevel.ValueChanged += LevelSelector_ValueChanged;
            dollDummy = v.FindViewById <NumberPicker>(Resource.Id.CalcAreaExpDollDummy);
            dollDummy.ValueChanged += LevelSelector_ValueChanged;
            warCount = v.FindViewById <NumberPicker>(Resource.Id.CalcAreaExpWarCount);
            warCount.ValueChanged                     += LevelSelector_ValueChanged;
            nowExpEditText                             = v.FindViewById <EditText>(Resource.Id.CalcAreaExpNowExp);
            nowExpEditText.TextChanged                += delegate { CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value); };
            commanderCostumeBonusEditText              = v.FindViewById <EditText>(Resource.Id.CalcAreaExpCommanderCostumeBonus);
            commanderCostumeBonusEditText.TextChanged += delegate { CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value); };
            applyVow = v.FindViewById <ToggleButton>(Resource.Id.CalcAreaExpVowSelector);
            applyVow.CheckedChange += delegate
            {
                isVow = applyVow.Checked;
                CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value);
            };
            applyExpEvent = v.FindViewById <ToggleButton>(Resource.Id.CalcAreaExpExpEventSelector);
            applyExpEvent.CheckedChange += delegate
            {
                isExpEvent = applyExpEvent.Checked;
                CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value);
            };
            applyAutoAddDummy = v.FindViewById <ToggleButton>(Resource.Id.CalcAreaExpAutoAddDummySelector);
            applyAutoAddDummy.CheckedChange += delegate
            {
                isAutoAddDummy = applyAutoAddDummy.Checked;
                CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value);
            };
            lastEnemy = v.FindViewById <ToggleButton>(Resource.Id.CalcAreaExpLastEnemySelector);
            lastEnemy.CheckedChange += delegate
            {
                hasLastEnemy = lastEnemy.Checked;
                CalcCount(nowLevel.Value, targetLevel.Value, dollDummy.Value, warCount.Value);
            };
            resultNormal    = v.FindViewById <TextView>(Resource.Id.CalcAreaExpResult_Normal);
            resultLeader    = v.FindViewById <TextView>(Resource.Id.CalcAreaExpResult_Leader);
            resultMVP       = v.FindViewById <TextView>(Resource.Id.CalcAreaExpResult_MVP);
            resultLeaderMVP = v.FindViewById <TextView>(Resource.Id.CalcAreaExpResult_Leader_MVP);

            // Set Option Icon Size

            DisplayMetrics dm    = Context.Resources.DisplayMetrics;
            int            width = dm.WidthPixels / 2;

            applyVow.LayoutParameters.Width           = width;
            applyVow.LayoutParameters.Height          = width;
            applyExpEvent.LayoutParameters.Width      = width;
            applyExpEvent.LayoutParameters.Height     = width;
            applyAutoAddDummy.LayoutParameters.Width  = width;
            applyAutoAddDummy.LayoutParameters.Height = width;
            lastEnemy.LayoutParameters.Width          = width;
            lastEnemy.LayoutParameters.Height         = width;

            _ = InitializeProcess();

            return(v);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.settings);
            easy            = FindViewById <RadioButton>(Resource.Id.radioEasy);
            normal          = FindViewById <RadioButton>(Resource.Id.radioNormal);
            hard            = FindViewById <RadioButton>(Resource.Id.radioHard);
            redBar          = FindViewById <SeekBar>(Resource.Id.seekBarRed);
            greenBar        = FindViewById <SeekBar>(Resource.Id.seekBarGreen);
            blueBar         = FindViewById <SeekBar>(Resource.Id.seekBlue);
            imgPreview      = FindViewById <ImageView>(Resource.Id.imgThemePreview);
            playerSelect    = FindViewById <SeekBar>(Resource.Id.seekBarPlayer);
            ballSelect      = FindViewById <SeekBar>(Resource.Id.seekBarBall);
            txtPlayerSelect = FindViewById <TextView>(Resource.Id.txtPlayerSelect);
            txtBallSelect   = FindViewById <TextView>(Resource.Id.txtBallSelect);
            sensivityBar    = FindViewById <SeekBar>(Resource.Id.seekBarSensivity);
            maxScore        = FindViewById <SeekBar>(Resource.Id.seekBarMaxScore);
            txtMaxScore     = FindViewById <TextView>(Resource.Id.txtMaxScore);
            paddleToggle    = FindViewById <ToggleButton>(Resource.Id.togglePaddle);
            debugToggle     = FindViewById <ToggleButton>(Resource.Id.toggleDebug);

            //Preserve settings after switching screens
            loadSettings();

            easy.CheckedChange += (e, o) =>
            {
                if (easy.Checked)
                {
                    Settings.Difficulty = 1;
                }
            };

            normal.CheckedChange += (e, o) =>
            {
                if (normal.Checked)
                {
                    Settings.Difficulty = 2;
                }
            };

            hard.CheckedChange += (e, o) =>
            {
                if (hard.Checked)
                {
                    Settings.Difficulty = 3;
                }
            };

            paddleToggle.CheckedChange += (e, o) =>
            {
                Settings.RightPaddle = paddleToggle.Checked;
            };

            debugToggle.CheckedChange += (e, o) =>
            {
                Settings.DebugMode = debugToggle.Checked == false ? 0 : 1;
            };

            redBar.ProgressChanged += (e, o) =>
            {
                Settings.R = redBar.Progress;
                imgPreview.SetColorFilter(new Color(redBar.Progress, greenBar.Progress, blueBar.Progress));
            };

            greenBar.ProgressChanged += (e, o) =>
            {
                Settings.G = greenBar.Progress;
                imgPreview.SetColorFilter(new Color(redBar.Progress, greenBar.Progress, blueBar.Progress));
            };

            blueBar.ProgressChanged += (e, o) =>
            {
                Settings.B = blueBar.Progress;
                imgPreview.SetColorFilter(new Color(redBar.Progress, greenBar.Progress, blueBar.Progress));
            };

            sensivityBar.ProgressChanged += (e, o) =>
            {
                Settings.Sensivity = sensivityBar.Progress;
            };

            playerSelect.ProgressChanged += (e, o) =>
            {
                Settings.player = playerSelect.Progress;
                switch (playerSelect.Progress)
                {
                case 0: { Settings.player = 0; txtPlayerSelect.Text = "Player model: Metallic"; } break;

                case 1: { Settings.player = 1; txtPlayerSelect.Text = "Player model: Laser"; } break;

                case 2: { Settings.player = 2; txtPlayerSelect.Text = "Player model: Plank"; } break;

                default: { Settings.player = 0; txtPlayerSelect.Text = "Player model: Metallic"; } break;
                }
            };

            ballSelect.ProgressChanged += (e, o) =>
            {
                Settings.ball = ballSelect.Progress;
                switch (ballSelect.Progress)
                {
                case 0: { Settings.ball = 0; txtBallSelect.Text = "Ball model: Meteor"; } break;

                case 1: { Settings.ball = 1; txtBallSelect.Text = "Ball model: Football"; } break;

                case 2: { Settings.ball = 2; txtBallSelect.Text = "Ball model: Cannonball"; } break;

                default: { Settings.ball = 0; txtBallSelect.Text = "Ball model: Meteor"; } break;
                }
            };

            maxScore.ProgressChanged += (e, o) =>
            {
                Settings.maxScore = maxScore.Progress;
                txtMaxScore.Text  = "Max game points: " + maxScore.Progress;
            };
        }
示例#38
0
 public ToggleButtonExAutomationPeer(ToggleButton owner)
     : base(owner)
 {
 }
示例#39
0
        public void Initialize(IPadWindow window)
        {
            this.window      = window;
            window.PadShown += delegate {
                if (needsReload)
                {
                    Refresh();
                }
            };

            DockItemToolbar toolbar = window.GetToolbar(PositionType.Top);

            errorBtn        = new ToggleButton();
            errorBtn.Active = (bool)PropertyService.Get(showErrorsPropertyName, true);
            string errorTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Error) != EnabledLoggingLevel.Error &&
                (InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Fatal) != EnabledLoggingLevel.Fatal)
            {
                errorBtn.Sensitive = false;
                errorTipText       = GettextCatalog.GetString("Logging of errors is not enabled");
            }
            else
            {
                errorTipText = GettextCatalog.GetString("Show errors");
            }
            errorBtn.Image = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Menu);
            errorBtn.Image.Show();
            errorBtn.Toggled    += new EventHandler(FilterChanged);
            errorBtn.TooltipText = errorTipText;
            UpdateErrorsNum();
            toolbar.Add(errorBtn);

            warnBtn        = new ToggleButton();
            warnBtn.Active = (bool)PropertyService.Get(showWarningsPropertyName, true);
            string warnTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Warn) != EnabledLoggingLevel.Warn)
            {
                warnBtn.Sensitive = false;
                warnTipText       = GettextCatalog.GetString("Logging of warnings is not enabled");
            }
            else
            {
                warnTipText = GettextCatalog.GetString("Show warnings");
            }
            warnBtn.Image = new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu);
            warnBtn.Image.Show();
            warnBtn.Toggled    += new EventHandler(FilterChanged);
            warnBtn.TooltipText = warnTipText;
            UpdateWarningsNum();
            toolbar.Add(warnBtn);

            msgBtn        = new ToggleButton();
            msgBtn.Active = (bool)PropertyService.Get(showMessagesPropertyName, true);
            string msgTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Info) != EnabledLoggingLevel.Info)
            {
                msgBtn.Sensitive = false;
                msgTipText       = GettextCatalog.GetString("Logging of informational messages is not enabled");
            }
            else
            {
                msgTipText = GettextCatalog.GetString("Show messages");
            }
            msgBtn.Image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu);
            msgBtn.Image.Show();
            msgBtn.Toggled    += new EventHandler(FilterChanged);
            msgBtn.TooltipText = msgTipText;
            UpdateMessagesNum();
            toolbar.Add(msgBtn);

            debugBtn        = new ToggleButton();
            debugBtn.Active = (bool)PropertyService.Get(showDebugPropertyName, true);
            string debugTipText;

            if ((InternalLog.EnabledLoggingLevel & EnabledLoggingLevel.Debug) != EnabledLoggingLevel.Debug)
            {
                debugBtn.Sensitive = false;
                debugTipText       = GettextCatalog.GetString("Logging of debug messages is not enabled");
            }
            else
            {
                debugTipText = GettextCatalog.GetString("Show debug");
            }
            debugBtn.Image = new Gtk.Image(Gtk.Stock.DialogQuestion, Gtk.IconSize.Menu);
            debugBtn.Image.Show();
            debugBtn.Toggled    += new EventHandler(FilterChanged);
            debugBtn.TooltipText = debugTipText;
            UpdateDebugNum();
            toolbar.Add(debugBtn);

            toolbar.Add(new SeparatorToolItem());

            Gtk.Button clearBtn = new Gtk.Button(new Gtk.Image(Gtk.Stock.Clear, Gtk.IconSize.Menu));
            clearBtn.Clicked += new EventHandler(OnClearList);
            toolbar.Add(clearBtn);
            toolbar.ShowAll();

            // Content

            store = new Gtk.ListStore(typeof(Gdk.Pixbuf),                    // image - type
                                      typeof(string),                        // desc
                                      typeof(string),                        // time
                                      typeof(string),                        // type string
                                      typeof(LogMessage));                   // message

            TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc(FilterTaskTypes);

            filter             = new TreeModelFilter(store, null);
            filter.VisibleFunc = filterFunct;

            view                  = new MonoDevelop.Ide.Gui.Components.PadTreeView(new Gtk.TreeModelSort(filter));
            view.RulesHint        = true;
            view.HeadersClickable = true;
            view.Selection.Mode   = SelectionMode.Multiple;

            view.DoPopupMenu = (evt) =>
                               IdeApp.CommandService.ShowContextMenu(view, evt, new CommandEntrySet()
            {
                new CommandEntry(EditCommands.Copy),
                new CommandEntry(EditCommands.SelectAll),
            });

            AddColumns();

            sw            = new Gtk.ScrolledWindow();
            sw.ShadowType = ShadowType.None;
            sw.Add(view);

            LoggingService.AddLogger(this);

            iconWarning = sw.RenderIcon(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu, "");
            iconError   = sw.RenderIcon(Gtk.Stock.DialogError, Gtk.IconSize.Menu, "");
            iconInfo    = sw.RenderIcon(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu, "");
            iconDebug   = sw.RenderIcon(Gtk.Stock.DialogQuestion, Gtk.IconSize.Menu, "");

            control = sw;
            sw.ShowAll();

            Refresh();

            store.SetSortFunc((int)Columns.Time, TimeSortFunc);
            ((TreeModelSort)view.Model).SetSortColumnId((int)Columns.Time, SortType.Descending);
        }
示例#40
0
        /// <summary>
        /// 添加预览
        /// </summary>
        /// <param name="img"></param>
        /// <param name="parentIndex"></param>
        /// <param name="needReferer"></param>
        public void AddPreview(Img img, int parentIndex, string needReferer)
        {
            if (!imgs.ContainsKey(img.Id))
            {
                imgs.Add(img.Id, index++);
                oriIndex.Add(img.Id, parentIndex);
                descs.Add(img.Id, img);
                //添加预览图分页按钮
                ToggleButton btn = new ToggleButton
                {
                    Content = img.Id,
                    Margin  = new Thickness(3, 1, 3, 1)
                };
                btn.Checked += new RoutedEventHandler(btn_Click);
                btns.Children.Add(btn);

                //初始化预览图
                PreviewImg prei = new PreviewImg(this, img);
                prei.MouseLeftButtonUp += new MouseButtonEventHandler(delegate(object s1, MouseButtonEventArgs ea)
                {
                    preMX = 0; preMY = 0;
                });
                prei.MouseLeftButtonDown += new MouseButtonEventHandler(delegate(object s1, MouseButtonEventArgs ea)
                {
                    preMX = 0; preMY = 0;
                });
                prei.MouseDown += new MouseButtonEventHandler(delegate(object s1, MouseButtonEventArgs ea)
                {
                    //中键缩放
                    if (ea.MiddleButton == MouseButtonState.Pressed)
                    {
                        Button_Click_2(null, null);
                    }
                });
                prei.MouseMove += new MouseEventHandler(delegate(object s1, MouseEventArgs ea)
                {
                    //拖动
                    if (ea.LeftButton == MouseButtonState.Pressed)
                    {
                        if (preMY != 0 && preMX != 0)
                        {
                            int offX        = (int)(ea.GetPosition(LayoutRoot).X) - preMX;
                            int offY        = (int)(ea.GetPosition(LayoutRoot).Y) - preMY;
                            ScrollViewer sc = (imgGrid.Children[imgs[selectedId]] as ScrollViewer);
                            sc.ScrollToHorizontalOffset(sc.HorizontalOffset - offX);
                            sc.ScrollToVerticalOffset(sc.VerticalOffset - offY);
                        }
                        preMX = (int)(ea.GetPosition(LayoutRoot).X);
                        preMY = (int)(ea.GetPosition(LayoutRoot).Y);
                    }
                });

                //加入预览图控件
                imgGrid.Children.Add(new ScrollViewer()
                {
                    Content    = prei,
                    Visibility = Visibility.Hidden,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled
                });

                //开始下载图片
                prei.DownloadImg(needReferer);

                if (selectedId == 0)
                {
                    (btns.Children[btns.Children.Count - 1] as ToggleButton).IsChecked = true;
                }
            }
        }
示例#41
0
        /// <summary>
        /// 根据不同类型的属性得到不同控件
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private static UIElement GetEditorControl(IStyle tool, PropertyInfo info)
        {
            StackPanel panel = new StackPanel();

            panel.Margin      = new Thickness(5);
            panel.Orientation = Orientation.Horizontal;

            var styleAttr = info.GetCustomAttributes(typeof(StyleAttribute), true).FirstOrDefault();

            if (styleAttr != null)
            {
                StyleAttribute style = styleAttr as StyleAttribute;

                if (style.DisplayName != "")
                {
                    TextBlock textblock = new TextBlock();
                    textblock.Text = style.DisplayName + ":";
                    textblock.VerticalAlignment = VerticalAlignment.Center;
                    panel.Children.Add(textblock);
                }

                if (info.PropertyType == typeof(double))
                {
                    TextBox textbox = new TextBox();
                    textbox.VerticalAlignment = VerticalAlignment.Center;
                    textbox.Width             = 40;
                    panel.Children.Add(textbox);

                    Binding bind = new Binding();
                    bind.Path = new PropertyPath(info.Name);
                    bind.Mode = style.Editable ? BindingMode.TwoWay : BindingMode.OneWay;

                    textbox.SetBinding(TextBox.TextProperty, bind);

                    if (!style.Editable)
                    {
                        textbox.IsReadOnly = true;
                    }
                }
                else if (info.PropertyType == typeof(Point))
                {
                    TextBlock textX = new TextBlock()
                    {
                        Text = "X"
                    };
                    textX.VerticalAlignment = VerticalAlignment.Center;
                    TextBox tbX = new TextBox();
                    tbX.VerticalAlignment = VerticalAlignment.Center;
                    tbX.Width             = 40;

                    Binding bind = new Binding();
                    bind.Path         = new PropertyPath(info.Name + ".X");
                    bind.Mode         = style.Editable ? BindingMode.TwoWay : BindingMode.OneWay;
                    bind.StringFormat = "0";
                    tbX.SetBinding(TextBox.TextProperty, bind);

                    TextBlock textY = new TextBlock()
                    {
                        Text = "Y"
                    };
                    textY.Margin            = new Thickness(5, 0, 0, 0);
                    textY.VerticalAlignment = VerticalAlignment.Center;

                    TextBox tbY = new TextBox();
                    tbY.VerticalAlignment = VerticalAlignment.Center;
                    tbY.Width             = 40;

                    bind              = new Binding();
                    bind.Path         = new PropertyPath(info.Name + ".Y");
                    bind.Mode         = style.Editable ? BindingMode.TwoWay : BindingMode.OneWay;
                    bind.StringFormat = "0";
                    tbY.SetBinding(TextBox.TextProperty, bind);

                    panel.Children.Add(textX);
                    panel.Children.Add(tbX);
                    panel.Children.Add(textY);
                    panel.Children.Add(tbY);
                }
                else if (info.PropertyType == typeof(DashStyle))
                {
                    ComboBox cbBox = new ComboBox();

                    panel.Children.Add(cbBox);
                }
                else if (info.PropertyType == typeof(Brush))
                {
                    ToggleButton btn = new ToggleButton();
                    btn.Width = 40;

                    Binding bind = new Binding();
                    bind.Path = new PropertyPath(info.Name);
                    bind.Mode = style.Editable ? BindingMode.TwoWay : BindingMode.OneWay;
                    btn.SetBinding(ToggleButton.BackgroundProperty, bind);

                    if (!style.Editable)
                    {
                        btn.IsEnabled = false;
                    }

                    panel.Children.Add(btn);
                }
                else if (info.PropertyType == typeof(System.Drawing.Font))
                {
                    TextBlock font = new TextBlock();
                    font.VerticalAlignment = VerticalAlignment.Center;
                    Binding bind = new Binding();
                    bind.Path = new PropertyPath(info.Name + ".Name");
                    font.SetBinding(TextBlock.TextProperty, bind);
                    panel.Children.Add(font);

                    panel.Children.Add(new TextBlock()
                    {
                        Text = " "
                    });

                    TextBlock size = new TextBlock();
                    size.VerticalAlignment = VerticalAlignment.Center;
                    bind              = new Binding();
                    bind.Path         = new PropertyPath(info.Name + ".Size");
                    bind.StringFormat = "0.00";
                    size.SetBinding(TextBlock.TextProperty, bind);
                    panel.Children.Add(size);

                    Button btn = new Button();
                    btn.Margin  = new Thickness(5, 0, 0, 0);
                    btn.Content = "设置";
                    btn.Click  += delegate
                    {
                        System.Windows.Forms.FontDialog dlg = new System.Windows.Forms.FontDialog();
                        dlg.Font = info.GetValue(tool) as System.Drawing.Font;

                        if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                        {
                            info.SetValue(tool, dlg.Font);
                        }
                    };

                    panel.Children.Add(btn);
                }
                else if (info.PropertyType == typeof(string))
                {
                    TextBox tb = new TextBox();
                    tb.Width         = 100;
                    tb.AcceptsReturn = true;
                    tb.MaxHeight     = 50;
                    tb.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;

                    Binding bind = new Binding();
                    bind.Path = new PropertyPath(info.Name);
                    tb.SetBinding(TextBox.TextProperty, bind);

                    panel.Children.Add(tb);
                }

                if (!string.IsNullOrEmpty(style.Measure))
                {
                    TextBlock textblock = new TextBlock();
                    textblock.Text = style.Measure;
                    textblock.VerticalAlignment = VerticalAlignment.Center;
                    panel.Children.Add(textblock);
                }

                if (!string.IsNullOrEmpty(style.ToolTip))
                {
                    Button btn = new Button();
                    btn.Content           = "?";
                    btn.Height            = 20;
                    btn.Width             = 20;
                    btn.VerticalAlignment = VerticalAlignment.Center;
                    btn.ToolTip           = style.ToolTip;
                    btn.Margin            = new Thickness(10, 0, 0, 0);

                    panel.Children.Add(btn);
                }
            }
            else
            {
                return(null);
            }

            return(panel);
        }
示例#42
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            if (Template != null)
            {
                ViewHost = Template.FindName("PART_ViewHost", this) as FrameworkElement;
                if (ViewHost != null)
                {
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.ToggleMainMenuCommand, Key = Key.F1
                    });
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.PrevFilterViewCommand, Key = Key.F2
                    });
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.NextFilterViewCommand, Key = Key.F3
                    });
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.SwitchToDesktopCommand, Key = Key.F11
                    });
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.OpenSearchCommand, Key = Key.Y
                    });
                    ViewHost.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.ToggleFiltersCommand, Key = Key.F
                    });

                    ViewHost.InputBindings.Add(new XInputBinding(mainModel.ToggleMainMenuCommand, XInputButton.Back));
                    ViewHost.InputBindings.Add(new XInputBinding(mainModel.PrevFilterViewCommand, XInputButton.LeftShoulder));
                    ViewHost.InputBindings.Add(new XInputBinding(mainModel.NextFilterViewCommand, XInputButton.RightShoulder));
                    ViewHost.InputBindings.Add(new XInputBinding(mainModel.OpenSearchCommand, XInputButton.Y));
                    ViewHost.InputBindings.Add(new XInputBinding(mainModel.ToggleFiltersCommand, XInputButton.RightStick));
                }

                MainHost = Template.FindName("PART_MainHost", this) as FrameworkElement;
                if (MainHost != null)
                {
                    BindingTools.SetBinding(MainHost, FrameworkElement.WidthProperty, mainModel, nameof(FullscreenAppViewModel.ViewportWidth));
                    BindingTools.SetBinding(MainHost, FrameworkElement.HeightProperty, mainModel, nameof(FullscreenAppViewModel.ViewportHeight));
                }

                AssignButtonWithCommand(ref ButtonMainMenu, "PART_ButtonMainMenu", mainModel.ToggleMainMenuCommand);
                AssignButtonWithCommand(ref ButtonNotifications, "PART_ButtonNotifications", mainModel.ToggleNotificationsCommand);

                ToggleFilterRecently = Template.FindName("PART_ToggleFilterRecently", this) as ToggleButton;
                if (ToggleFilterRecently != null)
                {
                    BindingTools.SetBinding(
                        ToggleFilterRecently,
                        ToggleButton.IsCheckedProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ActiveView),
                        BindingMode.TwoWay,
                        converter: new EnumToBooleanConverter(),
                        converterParameter: ActiveFullscreenView.RecentlyPlayed);
                }

                ToggleFilterFavorite = Template.FindName("PART_ToggleFilterFavorite", this) as ToggleButton;
                if (ToggleFilterFavorite != null)
                {
                    BindingTools.SetBinding(
                        ToggleFilterFavorite,
                        ToggleButton.IsCheckedProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ActiveView),
                        BindingMode.TwoWay,
                        converter: new EnumToBooleanConverter(),
                        converterParameter: ActiveFullscreenView.Favorites);
                }

                ToggleFilterMostPlayed = Template.FindName("PART_ToggleFilterMostPlayed", this) as ToggleButton;
                if (ToggleFilterMostPlayed != null)
                {
                    BindingTools.SetBinding(
                        ToggleFilterMostPlayed,
                        ToggleButton.IsCheckedProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ActiveView),
                        BindingMode.TwoWay,
                        converter: new EnumToBooleanConverter(),
                        converterParameter: ActiveFullscreenView.MostPlayed);
                }

                ToggleFilterAll = Template.FindName("PART_ToggleFilterAll", this) as ToggleButton;
                if (ToggleFilterAll != null)
                {
                    BindingTools.SetBinding(
                        ToggleFilterAll,
                        ToggleButton.IsCheckedProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ActiveView),
                        BindingMode.TwoWay,
                        converter: new EnumToBooleanConverter(),
                        converterParameter: ActiveFullscreenView.All);
                }

                TextClock = Template.FindName("PART_TextClock", this) as TextBlock;
                if (TextClock != null)
                {
                    BindingTools.SetBinding(TextClock, TextBlock.TextProperty, mainModel.CurrentTime, nameof(ObservableTime.Time));
                    BindingTools.SetBinding(
                        TextClock,
                        TextBlock.VisibilityProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ShowClock),
                        converter: new Converters.BooleanToVisibilityConverter());
                }

                TextBatteryPercentage = Template.FindName("PART_TextBatteryPercentage", this) as TextBlock;
                if (TextBatteryPercentage != null)
                {
                    BindingTools.SetBinding(TextBatteryPercentage,
                                            TextBlock.TextProperty,
                                            mainModel.PowerStatus,
                                            nameof(ObservablePowerStatus.PercentCharge),
                                            stringFormat: "{0}%");
                    BindingTools.SetBinding(TextBatteryPercentage,
                                            TextBlock.VisibilityProperty,
                                            mainModel.AppSettings.Fullscreen,
                                            nameof(FullscreenSettings.ShowBatteryPercentage),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemBatteryStatus = Template.FindName("PART_ElemBatteryStatus", this) as FrameworkElement;
                if (ElemBatteryStatus != null)
                {
                    BindingTools.SetBinding(
                        ElemBatteryStatus,
                        TextBlock.VisibilityProperty,
                        mainModel.AppSettings.Fullscreen,
                        nameof(FullscreenSettings.ShowBattery),
                        converter: new Converters.BooleanToVisibilityConverter());
                }

                TextProgressTooltip = Template.FindName("PART_TextProgressTooltip", this) as TextBlock;
                if (TextProgressTooltip != null)
                {
                    BindingTools.SetBinding(TextProgressTooltip, TextBlock.TextProperty, mainModel, nameof(FullscreenAppViewModel.ProgressStatus));
                    BindingTools.SetBinding(TextProgressTooltip,
                                            TextBlock.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.ProgressVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemProgressIndicator = Template.FindName("PART_ElemProgressIndicator", this) as FrameworkElement;
                if (ElemProgressIndicator != null)
                {
                    BindingTools.SetBinding(ElemProgressIndicator,
                                            ToggleButton.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.ProgressVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemExtraFilterActive = Template.FindName("PART_ElemExtraFilterActive", this) as FrameworkElement;
                if (ElemExtraFilterActive != null)
                {
                    BindingTools.SetBinding(ElemExtraFilterActive,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.IsExtraFilterActive),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemSearchActive = Template.FindName("PART_ElemSearchActive", this) as FrameworkElement;
                if (ElemSearchActive != null)
                {
                    BindingTools.SetBinding(ElemSearchActive,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.IsSearchActive),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ListGameItems = Template.FindName("PART_ListGameItems", this) as ListBox;
                if (ListGameItems != null)
                {
                    ListGameItems.ItemsPanel = GetItemsPanelTemplate();
                    ListGameItems.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.ToggleGameOptionsCommand, Key = Key.X
                    });
                    ListGameItems.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.ToggleGameDetailsCommand, Key = Key.A
                    });
                    ListGameItems.InputBindings.Add(new KeyBinding()
                    {
                        Command = mainModel.ActivateSelectedCommand, Key = Key.Enter
                    });

                    ListGameItems.InputBindings.Add(new XInputBinding(mainModel.ToggleGameOptionsCommand, XInputButton.Start));
                    ListGameItems.InputBindings.Add(new XInputBinding(mainModel.ToggleGameDetailsCommand, XInputButton.A));
                    ListGameItems.InputBindings.Add(new XInputBinding(mainModel.ActivateSelectedCommand, XInputButton.X));

                    BindingTools.SetBinding(ListGameItems,
                                            ListBox.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.GameListVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                    BindingTools.SetBinding(ListGameItems,
                                            ListBox.SelectedItemProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.SelectedGame),
                                            BindingMode.TwoWay);
                    BindingTools.SetBinding(ListGameItems,
                                            ListBox.ItemsSourceProperty,
                                            mainModel,
                                            $"{nameof(FullscreenAppViewModel.GamesView)}.{nameof(FullscreenCollectionView.CollectionView)}");
                    BindingTools.SetBinding(ListGameItems,
                                            FocusBahaviors.FocusBindingProperty,
                                            mainModel,
                                            nameof(mainModel.GameListFocused));
                    BindingTools.SetBinding(ListGameItems,
                                            FocusBahaviors.FocusBindingProperty,
                                            mainModel,
                                            nameof(mainModel.GameListFocused));

                    //Image gameBackground = Template.FindName("PART_GameBackground", this) as Image;
                    //BindingTools.SetBinding(gameBackground,
                    //    Image.SourceProperty,
                    //    mainModel,
                    //    nameof(mainModel.SelectedGame.BackgroundImage));
                }

                AssignButtonWithCommand(ref ButtonInstall, "PART_ButtonInstall", mainModel.ActivateSelectedCommand);
                BindingTools.SetBinding(
                    ButtonInstall,
                    ButtonBase.VisibilityProperty,
                    mainModel,
                    $"{nameof(FullscreenAppViewModel.SelectedGame)}.{nameof(GamesCollectionViewEntry.IsInstalled)}",
                    converter: new InvertedBooleanToVisibilityConverter(),
                    fallBackValue: Visibility.Collapsed);

                AssignButtonWithCommand(ref ButtonPlay, "PART_ButtonPlay", mainModel.ActivateSelectedCommand);
                BindingTools.SetBinding(
                    ButtonPlay,
                    ButtonBase.VisibilityProperty,
                    mainModel,
                    $"{nameof(FullscreenAppViewModel.SelectedGame)}.{nameof(GamesCollectionViewEntry.IsInstalled)}",
                    converter: new Converters.BooleanToVisibilityConverter(),
                    fallBackValue: Visibility.Collapsed);

                AssignButtonWithCommand(ref ButtonDetails, "PART_ButtonDetails", mainModel.ToggleGameDetailsCommand);
                BindingTools.SetBinding(
                    ButtonDetails,
                    ButtonBase.VisibilityProperty,
                    mainModel,
                    nameof(FullscreenAppViewModel.GameDetailsButtonVisible),
                    converter: new Converters.BooleanToVisibilityConverter());

                AssignButtonWithCommand(ref ButtonGameOptions, "PART_ButtonGameOptions", mainModel.ToggleGameOptionsCommand);
                BindingTools.SetBinding(
                    ButtonGameOptions,
                    ButtonBase.VisibilityProperty,
                    mainModel,
                    nameof(FullscreenAppViewModel.GameDetailsButtonVisible),
                    converter: new Converters.BooleanToVisibilityConverter());

                AssignButtonWithCommand(ref ButtonSearch, "PART_ButtonSearch", mainModel.OpenSearchCommand);
                AssignButtonWithCommand(ref ButtonFilter, "PART_ButtonFilter", mainModel.ToggleFiltersCommand);

                ElemNotifications = Template.FindName("PART_ElemNotifications", this) as FrameworkElement;
                if (ElemNotifications != null)
                {
                    BindingTools.SetBinding(ElemNotifications,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.NotificationsVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemMainMenu = Template.FindName("PART_ElemMainMenu", this) as FrameworkElement;
                if (ElemMainMenu != null)
                {
                    BindingTools.SetBinding(ElemMainMenu,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.MainMenuVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemSettingsMenu = Template.FindName("PART_ElemSettingsMenu", this) as FrameworkElement;
                if (ElemSettingsMenu != null)
                {
                    BindingTools.SetBinding(ElemSettingsMenu,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.SettingsMenuVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemGameMenu = Template.FindName("PART_ElemGameMenu", this) as FrameworkElement;
                if (ElemGameMenu != null)
                {
                    BindingTools.SetBinding(ElemGameMenu,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.GameMenuVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemFilters = Template.FindName("PART_ElemFilters", this) as FrameworkElement;
                if (ElemFilters != null)
                {
                    BindingTools.SetBinding(ElemFilters,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.FilterPanelVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ElemFiltersAdditional = Template.FindName("PART_ElemFiltersAdditional", this) as FrameworkElement;
                if (ElemFiltersAdditional != null)
                {
                    BindingTools.SetBinding(ElemFiltersAdditional,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.FilterAdditionalPanelVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                }

                ContentFilterItems = Template.FindName("PART_ContentFilterItems", this) as ContentControl;
                if (ContentFilterItems != null)
                {
                    BindingTools.SetBinding(ContentFilterItems,
                                            ContentControl.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.SubFilterVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                    BindingTools.SetBinding(ContentFilterItems,
                                            ContentControl.ContentProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.SubFilterControl));
                }

                ElemGameDetails = Template.FindName("PART_ElemGameDetails", this) as FrameworkElement;
                if (ElemGameDetails != null)
                {
                    BindingTools.SetBinding(ElemGameDetails,
                                            FrameworkElement.VisibilityProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.GameDetailsVisible),
                                            converter: new Converters.BooleanToVisibilityConverter());
                    BindingTools.SetBinding(ElemGameDetails,
                                            FrameworkElement.DataContextProperty,
                                            mainModel,
                                            nameof(FullscreenAppViewModel.GameDetailsEntry));
                }
            }
        }
示例#43
0
        private void Repopulate()
        {
            panelGroups             = new StackPanel();
            panelGroups.Orientation = Orientation.Vertical;

            borderMain.Content = panelGroups;

            _allButtons = new List <ToggleButton>();

            List <string> allGroups     = SearchProviderFactory.GetGroups();
            int           maxGroupItems = 0;

            foreach (string group in allGroups)
            {
                TextBlock tbTitle = new TextBlock();
                tbTitle.Text     = CultureHelper.GetString(Properties.Resources.ResourceManager, "SEARCHGROUP" + group.ToUpper());
                tbTitle.FontSize = 14;

                panelGroups.Children.Add(tbTitle);

                WrapPanel panelButtons = new WrapPanel();
                panelButtons.Orientation = Orientation.Horizontal;

                panelGroups.Children.Add(panelButtons);

                List <string> typeNames    = SearchProviderFactory.GetTypeNames(group);
                List <string> displayNames = SearchProviderFactory.GetDisplayNames(group);

                maxGroupItems = Math.Max(maxGroupItems, typeNames.Count);

                for (int i = 0; i < typeNames.Count; i++)
                {
                    ToggleButton button = new ToggleButton();
                    button.Tag = typeNames[i];

                    button.Width      = 70;
                    button.Height     = 70;
                    button.Checked   += new RoutedEventHandler(searchButton_Checked);
                    button.Unchecked += new RoutedEventHandler(searchButton_Unchecked);

                    StackPanel sp    = new StackPanel();
                    Image      image = new Image();
                    image.Width   = 40;
                    image.Height  = 40;
                    image.Stretch = System.Windows.Media.Stretch.Fill;
                    image.Source  = new BitmapImage(SearchProviderFactory.GetLargeImage(typeNames[i]));

                    TextBlock tb = new TextBlock();
                    tb.Text = displayNames[i];
                    tb.HorizontalAlignment = HorizontalAlignment.Center;

                    sp.Children.Add(image);
                    sp.Children.Add(tb);

                    button.Content = sp;

                    panelButtons.Children.Add(button);
                    _allButtons.Add(button);
                }
            }

            if (_allButtons.Count > 0)
            {
                _allButtons[0].IsChecked = true;
            }

            int columns = Math.Min(5, maxGroupItems);

            this.Width = (70 * columns) + 20;
            //this.Height = (Math.Ceiling((double)numItems / (double)columns) * 80) + 20;
        }
示例#44
0
        void UpdateItemCheckedState(ToggleButton button, DependencyProperty formattingProperty, object expectedValue)
        {
            object currentValue = NotesTextBox.Selection.GetPropertyValue(formattingProperty);

            button.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != null && currentValue.Equals(expectedValue);
        }
示例#45
0
        protected override void Render()
        {
            InlineCollection inlines = Inlines;

            while (inlines.Count > 1)
            {
                inlines.Remove(inlines.LastInline);
            }

            TwitterStatusViewer v = Owner;

            if (v == null)
            {
                return;
            }
            Status s = v.DataContext as Status;

            if (s == null)
            {
                return;
            }
            Status s1 = s;

            if (s.RetweetedStatus != null)
            {
                s = s.RetweetedStatus;
            }

            // 改行や連続する空白を削除
            string        text  = s.Text;
            StringBuilder sb    = new StringBuilder(text.Length);
            int           state = 0;

            for (int i = 0; i < text.Length; i++)
            {
                char c = text[i];
                if (c == '\r' || c == '\n')
                {
                    continue;
                }
                if (char.IsWhiteSpace(c))
                {
                    if (state == 1)
                    {
                        continue;
                    }
                    state = 1;
                }
                else
                {
                    state = 0;
                }
                sb.Append(text[i]);
            }
            text = sb.ToString();

            // Favoriteアイコン
            ToggleButton favBtn = v.CreateFavoriteButton(s);

            favBtn.Margin = new Thickness(0, 0, 3, 0);
            inlines.Add(favBtn);

            // 名前を追加
            RoutedEventHandler defLinkHandler = new RoutedEventHandler(v.Hyperlink_Click);
            DependencyProperty nameFg         = TwitterStatusViewer.NameForegroundProperty;

            inlines.Add(v.CreateHyperlink(s.User.ScreenName, "/" + s.User.ScreenName, nameFg, FontWeights.Bold, defLinkHandler));
            inlines.Add(" ");

            // 本文を追加
            v.CreateTweetBody(text, inlines);

            // 返信情報を追加
            if (!string.IsNullOrEmpty(s.InReplyToScreenName))
            {
                inlines.Add(v.CreateTextBlock(" in reply to ", FontWeights.Normal, nameFg));
                inlines.Add(v.CreateHyperlink("@" + s.InReplyToScreenName, "/" + s.InReplyToScreenName + (s.InReplyToStatusId == 0 ? string.Empty : "/status/" + s.InReplyToStatusId.ToString()), nameFg, FontWeights.Bold, defLinkHandler));
            }
            if (s != s1)
            {
                inlines.Add(v.CreateTextBlock(" RT by ", FontWeights.Normal, nameFg));
                inlines.Add(v.CreateHyperlink("@" + s1.User.ScreenName, "/" + s1.User.ScreenName, nameFg, FontWeights.Bold, defLinkHandler));
            }
        }
示例#46
0
        private TrainEditForm(Timetable tt)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            this.tt = tt;

            th = new TrainEditHelper();

            nameValidator = new NotEmptyValidator(nameTextBox, errorMessage: "Bitte einen Zugnamen eingeben!");

            daysBoxes = new[] { mondayCheckBox, tuesdayCheckBox, wednesdayCheckBox, thursdayCheckBox, fridayCheckBox, saturdayCheckBox, sundayCheckBox };
            foreach (var dayBox in daysBoxes)
            {
                dayBox.CheckedChanged += CheckBoxStateChanged;
            }

            locomotiveComboBox.Items.AddRange(GetAllItems(tt, t => t.Locomotive));
            lastComboBox.Items.AddRange(GetAllItems(tt, t => t.Last));
            mbrComboBox.Items.AddRange(GetAllItems(tt, t => t.Mbr));

            KeyDown += (s, e) =>
            {
                if (!e.Control)
                {
                    return;
                }

                var handled = true;
                if (new[] { Keys.D0, Keys.Keypad0 }.Contains(e.Key))
                {
                    ApplyShortcut(zShortcut);
                }
                else if (e.Key == Keys.A)
                {
                    ApplyShortcut(aShortcut);
                }
                else if (e.Key == Keys.W && e.Shift)
                {
                    ApplyShortcut(wExclSaShortcut);
                }
                else if (e.Key == Keys.W)
                {
                    ApplyShortcut(wShortcut);
                }
                else if (e.Key == Keys.S)
                {
                    ApplyShortcut(sShortcut);
                }
                else
                {
                    handled = false;
                }

                e.Handled = handled;
            };

            var shortcutsButtons = new[] { wShort, wSaShort, sShort, aShort, zShort };
            var shortcuts        = new[] { wShortcut, wExclSaShortcut, sShortcut, aShortcut, zShortcut };

            shortcutsToggle = new ToggleButton[shortcuts.Length];
            for (int i = 0; i < shortcutsButtons.Length; i++)
            {
                var toggle = new ToggleButton(shortcutsButtons[i])
                {
                    Tag          = shortcuts[i],
                    AllowDisable = false
                };
                toggle.ToggleClick += ApplyShortcutBtn;
                shortcutsToggle[i]  = toggle;
            }
        }
示例#47
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     _addScriptButton = this.FindControl <ToggleButton>("PART_AddScriptButton");
     _addScriptButton.GetObservable(ToggleButton.IsCheckedProperty).Subscribe(AddScriptButton_PointerPressed);
 }
 public void SelectStroketechnique(ToggleButton source)
 {
     if (source.Name.ToLower().Equals("push"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Push";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("pushaggressive"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "aggressive";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("flip"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Flip";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("banana"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Banana";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("topspin"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Topspin";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("topspinspin"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Spin";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("topspintempo"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Tempo";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("block"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Block";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("blockchop"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Chop";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("blocktempo"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Tempo";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("chop"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Chop";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("lob"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Lob";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("tetra"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Option = "Tetra";
         }
         else
         {
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("smash"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Smash";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("counter"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Counter";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
     else if (source.Name.ToLower().Equals("special"))
     {
         if (source.IsChecked.Value)
         {
             Stroke.Stroketechnique.Type   = "Special";
             Stroke.Stroketechnique.Option = "";
         }
         else
         {
             Stroke.Stroketechnique.Type   = "";
             Stroke.Stroketechnique.Option = "";
         }
     }
 }
示例#49
0
        public ToolsWindow()
            : base()
        {
            #region Set managers and UI references
            this.messages = GuiData.messages;
            this.sesgMan  = GameData.sesgMan;
            #endregion

            #region Set "this" properties
            base.SetPositionTL(106f, 5.8f);
            base.HasCloseButton = true;
            #endregion

            #region Move Button
            this.MoveButton      = AddToggleButton();
            this.MoveButton.Text = "Move";
            this.MoveButton.SetOverlayTextures(2, 0);
            #endregion

            #region Scale Button
            this.ScaleButton      = AddToggleButton();
            this.ScaleButton.Text = "Scale";
            this.MoveButton.AddToRadioGroup(this.ScaleButton);
            this.ScaleButton.SetOverlayTextures(1, 0);
            #endregion

            #region Rotate Button
            this.RotateButton      = AddToggleButton();
            this.RotateButton.Text = "Rotate";
            this.MoveButton.AddToRadioGroup(this.RotateButton);
            this.RotateButton.SetOverlayTextures(0, 0);
            #endregion

            #region Attach Sprite

            this.attachSprite      = base.AddToggleButton();
            this.attachSprite.Text = "Attach";
            this.MoveButton.AddToRadioGroup(this.attachSprite);
            this.attachSprite.SetOverlayTextures(7, 0);

            #endregion

            #region Detach Sprite

            this.detachSpriteButton         = AddButton();
            this.detachSpriteButton.Text    = "Detach";
            this.detachSpriteButton.Enabled = false;
            this.detachSpriteButton.SetOverlayTextures(10, 0);
            this.detachSpriteButton.Click += new GuiMessage(this.detachSprite);

            #endregion

            #region SetRootAsControlPoint
            this.setRootAsControlPoint         = AddButton();
            this.setRootAsControlPoint.Text    = "Set Root As Control Point";
            this.setRootAsControlPoint.Enabled = false;
            this.setRootAsControlPoint.SetOverlayTextures(12, 2);
            this.setRootAsControlPoint.Click += new GuiMessage(this.SetRootAsControlPointClick);
            #endregion

            #region Duplicate Objects

            this.mDuplicateObject      = AddButton();
            this.mDuplicateObject.Text = "Duplicate";
            this.mDuplicateObject.SetOverlayTextures(9, 0);
            this.mDuplicateObject.Click += new GuiMessage(this.CopyCurrentObjects);

            #endregion

            #region Convert to SpriteGrid
            this.convertToSpriteGridButton      = AddButton();
            this.convertToSpriteGridButton.Text = "Convert Sprite to SpriteGrid";
            this.convertToSpriteGridButton.SetOverlayTextures(2, 1);
            this.convertToSpriteGridButton.Enabled = false;
            this.convertToSpriteGridButton.Click  += new GuiMessage(SpriteGridGuiMessages.ConvertToSpriteGridButtonClick);
            #endregion

            #region Convert to SpriteFrame

            this.convertToSpriteFrame      = AddButton();
            this.convertToSpriteFrame.Text = "Convert Sprite to SpriteFrame";
            this.convertToSpriteFrame.SetOverlayTextures(1, 3);
            this.convertToSpriteFrame.Enabled = false;
            this.convertToSpriteFrame.Click  += new GuiMessage(GameData.sfMan.ConvertToSpriteFrameClick);

            #endregion

            #region Paint Button
            this.paintButton      = AddToggleButton();
            this.paintButton.Text = "Paint";
            this.paintButton.SetOverlayTextures(5, 1);
            this.MoveButton.AddToRadioGroup(this.paintButton);
            this.paintButton.Click += new GuiMessage(this.PaintButtonClicked);

            #endregion

            #region Current Texture Display

            this.currentTextureDisplay        = AddButton();
            this.currentTextureDisplay.Text   = "";
            this.currentTextureDisplay.Click += new GuiMessage(FileButtonWindow.openFileWindowLoadTexture);

            #endregion

            #region eyedropper

            this.eyedropper      = AddToggleButton();
            this.eyedropper.Text = "Eyedropper Tool";
            this.eyedropper.SetOverlayTextures(8, 1);
            this.MoveButton.AddToRadioGroup(this.eyedropper);

            #endregion

            #region Brush size

            this.brushSize = new ComboBox(mCursor);
            AddWindow(brushSize);
            this.brushSize.SetPositionTL(4.2f, 12.5f);
            this.brushSize.ScaleY = 1.3f;
            this.brushSize.ScaleX = 3.8f;
            this.brushSize.AddItem("1X1");
            this.brushSize.AddItem("3X3");
            this.brushSize.AddItem("5X5");
            this.brushSize.Text = "1X1";
            this.brushSize.ExpandOnTextBoxClick = true;

            #endregion

            this.constrainDimensions = base.AddToggleButton();
            this.constrainDimensions.SetPositionTL(constrainDimensions.X, 15.5f);
            this.constrainDimensions.Text = "Constrain Dim.";
            this.constrainDimensions.SetOverlayTextures(5, 0);

            #region Group/Hierarchy Button
            this.groupHierarchyControlButton = base.AddToggleButton();
            this.groupHierarchyControlButton.SetText("Group Control", "Hierarchy Control");
            this.groupHierarchyControlButton.SetOverlayTextures(3, 0, 4, 0);
            #endregion


            this.mSnapSprite      = base.AddToggleButton();
            this.mSnapSprite.Text = "Sprite Snapping";
            this.mSnapSprite.SetOverlayTextures(6, 0);

            #region DownZFreeRotateButton

            this.mDownZFreeRotateButton = base.AddToggleButton();


            mDownZFreeRotateButton.SetOverlayTextures(
                FlatRedBallServices.Load <Texture2D>(@"Content\DownZ.png", FlatRedBallServices.GlobalContentManager),
                FlatRedBallServices.Load <Texture2D>(@"Content\FreeRotation.png", FlatRedBallServices.GlobalContentManager));


            #endregion

            this.MinimumScaleX = this.ScaleX;
            this.MinimumScaleY = this.ScaleY;
        }
示例#50
0
        protected override void Initialize(IPadWindow window)
        {
            window.Title = GettextCatalog.GetString("Errors");

            DockItemToolbar toolbar = window.GetToolbar(DockPositionType.Top);

            toolbar.Accessible.Name = "ErrorPad.Toolbar";
            toolbar.Accessible.SetLabel("Error Pad Toolbar");
            toolbar.Accessible.SetRole("AXToolbar", "Pad toolbar");
            toolbar.Accessible.Description = GettextCatalog.GetString("The Error pad toolbar");

            errorBtn = MakeButton(Stock.Error, "toggleErrors", ShowErrors, out errorBtnLbl);
            errorBtn.Accessible.Name = "ErrorPad.ErrorButton";

            errorBtn.Toggled               += new EventHandler(FilterChanged);
            errorBtn.TooltipText            = GettextCatalog.GetString("Show Errors");
            errorBtn.Accessible.Description = GettextCatalog.GetString("Show Errors");
            UpdateErrorsNum();
            toolbar.Add(errorBtn);

            warnBtn = MakeButton(Stock.Warning, "toggleWarnings", ShowWarnings, out warnBtnLbl);
            warnBtn.Accessible.Name        = "ErrorPad.WarningButton";
            warnBtn.Toggled               += new EventHandler(FilterChanged);
            warnBtn.TooltipText            = GettextCatalog.GetString("Show Warnings");
            warnBtn.Accessible.Description = GettextCatalog.GetString("Show Warnings");
            UpdateWarningsNum();
            toolbar.Add(warnBtn);

            msgBtn = MakeButton(Stock.Information, "toggleMessages", ShowMessages, out msgBtnLbl);
            msgBtn.Accessible.Name        = "ErrorPad.MessageButton";
            msgBtn.Toggled               += new EventHandler(FilterChanged);
            msgBtn.TooltipText            = GettextCatalog.GetString("Show Messages");
            msgBtn.Accessible.Description = GettextCatalog.GetString("Show Messages");
            UpdateMessagesNum();
            toolbar.Add(msgBtn);

            var sep = new SeparatorToolItem();

            sep.Accessible.SetShouldIgnore(true);
            toolbar.Add(sep);

            logBtn = MakeButton("md-message-log", "toggleBuildOutput", out logBtnLbl);
            logBtn.Accessible.Name        = "ErrorPad.LogButton";
            logBtn.TooltipText            = GettextCatalog.GetString("Show build output");
            logBtn.Accessible.Description = GettextCatalog.GetString("Show build output");

            logBtnLbl.Text = GettextCatalog.GetString("Build Output");
            logBtn.Accessible.SetTitle(logBtnLbl.Text);

            logBtn.Clicked += HandleLogBtnClicked;
            toolbar.Add(logBtn);

            buildOutput = new BuildOutput();

            //Dummy widget to take all space between "Build Output" button and SearchEntry
            var spacer = new HBox();

            spacer.Accessible.SetShouldIgnore(true);
            toolbar.Add(spacer, true);

            searchEntry = new SearchEntry();
            searchEntry.Accessible.SetLabel(GettextCatalog.GetString("Search"));
            searchEntry.Accessible.Name        = "ErrorPad.Search";
            searchEntry.Accessible.Description = GettextCatalog.GetString("Search the error data");
            searchEntry.Entry.Changed         += searchPatternChanged;
            searchEntry.WidthRequest           = 200;
            searchEntry.Visible = true;
            toolbar.Add(searchEntry);

            toolbar.ShowAll();

            UpdatePadIcon();

            IdeApp.ProjectOperations.StartBuild += OnBuildStarted;
        }
示例#51
0
        protected override void Initialize(IPadWindow window)
        {
            window.Title = GettextCatalog.GetString("Errors");

            DockItemToolbar toolbar = window.GetToolbar(DockPositionType.Top);

            var btnBox = new HBox(false, 2);

            btnBox.PackStart(new ImageView(Stock.Error, Gtk.IconSize.Menu));
            errorBtnLbl = new Label();
            btnBox.PackStart(errorBtnLbl);

            errorBtn = new ToggleButton {
                Name = "toggleErrors"
            };
            errorBtn.Active      = ShowErrors;
            errorBtn.Child       = btnBox;
            errorBtn.Toggled    += new EventHandler(FilterChanged);
            errorBtn.TooltipText = GettextCatalog.GetString("Show Errors");
            UpdateErrorsNum();
            toolbar.Add(errorBtn);

            btnBox = new HBox(false, 2);
            btnBox.PackStart(new ImageView(Stock.Warning, Gtk.IconSize.Menu));
            warnBtnLbl = new Label();
            btnBox.PackStart(warnBtnLbl);

            warnBtn = new ToggleButton  {
                Name = "toggleWarnings"
            };
            warnBtn.Active      = ShowWarnings;
            warnBtn.Child       = btnBox;
            warnBtn.Toggled    += new EventHandler(FilterChanged);
            warnBtn.TooltipText = GettextCatalog.GetString("Show Warnings");
            UpdateWarningsNum();
            toolbar.Add(warnBtn);

            btnBox = new HBox(false, 2);
            btnBox.PackStart(new ImageView(Stock.Information, Gtk.IconSize.Menu));
            msgBtnLbl = new Label();
            btnBox.PackStart(msgBtnLbl);

            msgBtn = new ToggleButton  {
                Name = "toggleMessages"
            };
            msgBtn.Active      = ShowMessages;
            msgBtn.Child       = btnBox;
            msgBtn.Toggled    += new EventHandler(FilterChanged);
            msgBtn.TooltipText = GettextCatalog.GetString("Show Messages");
            UpdateMessagesNum();
            toolbar.Add(msgBtn);

            toolbar.Add(new SeparatorToolItem());

            btnBox = new HBox(false, 2);
            btnBox.PackStart(new ImageView("md-message-log", Gtk.IconSize.Menu));
            logBtnLbl = new Label(GettextCatalog.GetString("Build Output"));
            btnBox.PackStart(logBtnLbl);

            logBtn = new ToggleButton {
                Name = "toggleBuildOutput"
            };
            logBtn.Child       = btnBox;
            logBtn.TooltipText = GettextCatalog.GetString("Show build output");
            logBtn.Toggled    += HandleLogBtnToggled;
            toolbar.Add(logBtn);

            //Dummy widget to take all space between "Build Output" button and SearchEntry
            toolbar.Add(new HBox(), true);

            searchEntry = new SearchEntry();
            searchEntry.Entry.Changed += searchPatternChanged;
            searchEntry.WidthRequest   = 200;
            searchEntry.Visible        = true;
            toolbar.Add(searchEntry);

            toolbar.ShowAll();

            UpdatePadIcon();
        }
        public void Update(CommandTargetRoute targetRoute)
        {
            CommandInfo cmdInfo = IdeApp.CommandService.GetCommandInfo(cmdId, targetRoute);

            bool   hasAccel    = string.IsNullOrEmpty(cmdInfo.AccelKey);
            bool   hasIcon     = !cmdInfo.Icon.IsNull;
            string desc        = cmdInfo.Description;
            bool   displayText = !(displayType == CommandEntryDisplayType.IconHasPriority && hasIcon) &&
                                 displayType != CommandEntryDisplayType.IconOnly;

            //If the button only has an icon it's not always clear what it does. In such cases, use the label as a
            //fallback tooltip. Also do this if there's an accelerator, so the user can see what it is.
            if (string.IsNullOrEmpty(desc) && (!displayText || hasAccel))
            {
                desc = cmdInfo.Text;
            }

            if (lastDesc != desc)
            {
                string toolTip;
                if (hasAccel)
                {
                    toolTip = desc;
                }
                else
                {
                    toolTip = desc + " (" + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, false) + ")";
                }
                button.TooltipText = toolTip;
                lastDesc           = desc;
            }

            if (displayText && button.Label != cmdInfo.Text)
            {
                button.Label = cmdInfo.Text;
            }

            if (displayType != CommandEntryDisplayType.TextOnly && cmdInfo.Icon != stockId)
            {
                stockId      = cmdInfo.Icon;
                button.Image = new Gtk.Image(cmdInfo.Icon, Gtk.IconSize.Menu);
            }
            if (cmdInfo.Enabled != button.Sensitive)
            {
                button.Sensitive = cmdInfo.Enabled;
            }
            if (cmdInfo.Visible != button.Visible)
            {
                button.Visible = cmdInfo.Visible;
            }

            ToggleButton toggle = button as ToggleButton;

            if (toggle != null && cmdInfo.Checked != toggle.Active)
            {
                toggle.Active = cmdInfo.Checked;
            }

            if (button.Image != null)
            {
                button.Image.Show();
            }
        }
示例#53
0
 public void RemoveButton(ToggleButton button)
 {
     Buttons.Remove(button);
 }
示例#54
0
        private void StyleChange_Click(object sender, RoutedEventArgs e)
        {
            ToggleButton togBtn = (ToggleButton)sender;

            ChangeStyle(togBtn.Header as string);
        }
        public MultithreadingSample()
        {
            int r   = 0;
            var tbl = new Table();

            PackStart(tbl);

            tbl.Add(new Label("Application.Invoke:"), 0, r);
            tbl.Add(l1   = new Label("0"), 1, r);
            tbl.Add(btn1 = new ToggleButton("Run"), 2, r++);

            Task worker1;
            CancellationTokenSource worker1cancel = new CancellationTokenSource();;

            btn1.Toggled += delegate {
                if (btn1.Active)
                {
                    worker1cancel = new CancellationTokenSource();
                    worker1       = Task.Factory.StartNew(delegate {
                        int cnt = 0;
                        while (!worker1cancel.Token.IsCancellationRequested)
                        {
                            Thread.Sleep(50);
                            cnt++;
                            string txt = cnt.ToString();
                            Application.Invoke(() => l1.Text = txt);
                        }
                    }, worker1cancel.Token, TaskCreationOptions.LongRunning);
                }
                else
                {
                    worker1cancel.Cancel();
                }
            };


            tbl.Add(new Label("Application.UITaskScheduler:"), 0, r);
            tbl.Add(l2   = new Label("0"), 1, r);
            tbl.Add(btn2 = new ToggleButton("Run"), 2, r++);

            Task worker2;
            CancellationTokenSource worker2cancel = new CancellationTokenSource();;

            btn2.Toggled += delegate {
                if (btn2.Active)
                {
                    worker2cancel = new CancellationTokenSource();
                    worker2       = Task.Factory.StartNew(delegate {
                        int cnt = 0;
                        while (!worker2cancel.Token.IsCancellationRequested)
                        {
                            Thread.Sleep(50);
                            cnt++;
                            var txt = cnt.ToString();
                            Task.Factory.StartNew(delegate {
                                l2.Text = txt;
                            }, worker2cancel.Token, TaskCreationOptions.None, Application.UITaskScheduler);
                        }
                    }, worker2cancel.Token, TaskCreationOptions.LongRunning);
                }
                else
                {
                    worker2cancel.Cancel();
                }
            };


            tbl.Add(new Label("BackgroundWorker:\n(XwtSynchronizationContext.Post)"), 0, r);
            tbl.Add(l3   = new Label("0"), 1, r);
            tbl.Add(btn3 = new ToggleButton("Run"), 2, r++);

            var worker3 = new BackgroundWorker();

            worker3.WorkerReportsProgress      = true;
            worker3.WorkerSupportsCancellation = true;
            worker3.DoWork          += BackgroundWorkerDoWork;
            worker3.ProgressChanged += (sender, e) => l3.Text = e.ProgressPercentage.ToString();

            btn3.Toggled += delegate {
                if (btn3.Active)
                {
                    worker3.RunWorkerAsync();
                }
                else
                {
                    worker3.CancelAsync();
                }
            };


            tbl.Add(new Label("XwtSynchronizationContext.Send:"), 0, r);
            tbl.Add(l4   = new Label("0"), 1, r);
            tbl.Add(btn4 = new ToggleButton("Run"), 2, r++);

            worker4 = new SampleBGWorker();
            worker4.SynchronizationContext = SynchronizationContext.Current;
            worker4.InvokeSynchronized     = true;
            worker4.Count += HandleCount4;

            btn4.Toggled += delegate {
                if (btn4.Active)
                {
                    worker4.Start();
                }
                else
                {
                    worker4.Stop();
                }
            };


            tbl.Add(new Label("ISynchronizeInvoke.BeginInvoke:"), 0, r);
            tbl.Add(l5   = new Label("0"), 1, r);
            tbl.Add(btn5 = new ToggleButton("Run"), 2, r++);

            worker5 = new SampleBGWorker();
            worker5.InvokeSynchronized = false;
            worker5.Count += HandleCount5;

            btn5.Toggled += delegate {
                if (btn5.Active)
                {
                    worker5.Start();
                }
                else
                {
                    worker5.Stop();
                }
            };


            tbl.Add(new Label("ISynchronizeInvoke.Invoke:"), 0, r);
            tbl.Add(l6   = new Label("0"), 1, r);
            tbl.Add(btn6 = new ToggleButton("Run"), 2, r++);

            worker6 = new SampleBGWorker();
            worker6.InvokeSynchronized = true;
            worker6.Count += HandleCount6;

            btn6.Toggled += delegate {
                if (btn6.Active)
                {
                    worker6.Start();
                }
                else
                {
                    worker6.Stop();
                }
            };
        }
示例#56
0
        /// <summary>
        /// This method is used to create RibbonSample panel, and add wall related command buttons to it:
        /// 1. contains a SplitButton for user to create Non-Structural or Structural Wall;
        /// 2. contains a StackedBotton which is consisted with one PushButton and two Comboboxes,
        /// PushButon is used to reset all the RibbonItem, Comboboxes are use to select Level and WallShape
        /// 3. contains a RadioButtonGroup for user to select WallType.
        /// 4. Adds a Slide-Out Panel to existing panel with following functionalities:
        /// 5. a text box is added to set mark for new wall, mark is a instance parameter for wall,
        /// Eg: if user set text as "wall", then Mark for each new wall will be "wall1", "wall2", "wall3"....
        /// 6. a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction)
        /// </summary>
        /// <param name="application">An object that is passed to the external application
        /// which contains the controlled application.</param>
        private void CreateRibbonSamplePanel(UIControlledApplication application)
        {
            // create a Ribbon panel which contains three stackable buttons and one single push button.
            string      firstPanelName    = "Ribbon Sample";
            RibbonPanel ribbonSamplePanel = application.CreateRibbonPanel(firstPanelName);

            #region Create a SplitButton for user to create Non-Structural or Structural Wall
            SplitButtonData splitButtonData = new SplitButtonData("NewWallSplit", "Create Wall");
            SplitButton     splitButton     = ribbonSamplePanel.AddItem(splitButtonData) as SplitButton;
            PushButton      pushButton      = splitButton.AddPushButton(new PushButtonData("WallPush", "Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateWall"));
            pushButton.LargeImage   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall.png"), UriKind.Absolute));
            pushButton.Image        = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall-S.png"), UriKind.Absolute));
            pushButton.ToolTip      = "Creates a partition wall in the building model.";
            pushButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWallTooltip.bmp"), UriKind.Absolute));
            pushButton            = splitButton.AddPushButton(new PushButtonData("StrWallPush", "Structure Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateStructureWall"));
            pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall.png"), UriKind.Absolute));
            pushButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall-S.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Add a StackedButton which is consisted of one PushButton and two Comboboxes
            PushButtonData     pushButtonData     = new PushButtonData("Reset", "Reset", AddInPath, "Revit.SDK.Samples.Ribbon.CS.ResetSetting");
            ComboBoxData       comboBoxDataLevel  = new ComboBoxData("LevelsSelector");
            ComboBoxData       comboBoxDataShape  = new ComboBoxData("WallShapeComboBox");
            IList <RibbonItem> ribbonItemsStacked = ribbonSamplePanel.AddStackedItems(pushButtonData, comboBoxDataLevel, comboBoxDataShape);
            ((PushButton)(ribbonItemsStacked[0])).Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Reset.png"), UriKind.Absolute));
            //Add options to WallShapeComboBox
            Autodesk.Revit.UI.ComboBox comboboxWallShape  = (Autodesk.Revit.UI.ComboBox)(ribbonItemsStacked[2]);
            ComboBoxMemberData         comboBoxMemberData = new ComboBoxMemberData("RectangleWall", "RectangleWall");
            ComboBoxMember             comboboxMember     = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "RectangleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("CircleWall", "CircleWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CircleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("TriangleWall", "TriangleWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "TriangleWall.png"), UriKind.Absolute));
            comboBoxMemberData   = new ComboBoxMemberData("SquareWall", "SquareWall");
            comboboxMember       = comboboxWallShape.AddItem(comboBoxMemberData);
            comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "SquareWall.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Add a RadioButtonGroup for user to select WallType
            RadioButtonGroupData radioButtonGroupData = new RadioButtonGroupData("WallTypeSelector");
            RadioButtonGroup     radioButtonGroup     = (RadioButtonGroup)(ribbonSamplePanel.AddItem(radioButtonGroupData));
            ToggleButton         toggleButton         = radioButtonGroup.AddItem(new ToggleButtonData("Generic8", "Generic - 8\"", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy"));
            toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8.png"), UriKind.Absolute));
            toggleButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8-S.png"), UriKind.Absolute));
            toggleButton            = radioButtonGroup.AddItem(new ToggleButtonData("ExteriorBrick", "Exterior - Brick", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy"));
            toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick.png"), UriKind.Absolute));
            toggleButton.Image      = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick-S.png"), UriKind.Absolute));
            #endregion

            //slide-out panel:
            ribbonSamplePanel.AddSlideOut();

            #region add a Text box to set the mark for new wall
            TextBoxData testBoxData           = new TextBoxData("WallMark");
            Autodesk.Revit.UI.TextBox textBox = (Autodesk.Revit.UI.TextBox)(ribbonSamplePanel.AddItem(testBoxData));
            textBox.Value             = "new wall"; //default wall mark
            textBox.Image             = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "WallMark.png"), UriKind.Absolute));
            textBox.ToolTip           = "Set the mark for new wall";
            textBox.ShowImageAsButton = true;
            textBox.EnterPressed     += new EventHandler <Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(SetTextBoxValue);
            #endregion

            ribbonSamplePanel.AddSeparator();

            #region Create a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction)
            PushButtonData deleteWallsButtonData = new PushButtonData("deleteWalls", "Delete Walls", AddInPath, "Revit.SDK.Samples.Ribbon.CS.DeleteWalls");
            deleteWallsButtonData.ToolTip = "Delete all the walls created by the Create Wall tool.";
            deleteWallsButtonData.Image   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "DeleteWalls.png"), UriKind.Absolute));

            PulldownButtonData moveWallsButtonData = new PulldownButtonData("moveWalls", "Move Walls");
            moveWallsButtonData.ToolTip = "Move all the walls in X or Y direction";
            moveWallsButtonData.Image   = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWalls.png"), UriKind.Absolute));

            // create stackable buttons
            IList <RibbonItem> ribbonItems = ribbonSamplePanel.AddStackedItems(deleteWallsButtonData, moveWallsButtonData);

            // add two push buttons as sub-items of the moveWalls PulldownButton.
            PulldownButton moveWallItem = ribbonItems[1] as PulldownButton;

            PushButton moveX = moveWallItem.AddPushButton(new PushButtonData("XDirection", "X Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.XMoveWalls"));
            moveX.ToolTip    = "move all walls 10 feet in X direction.";
            moveX.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsXLarge.png"), UriKind.Absolute));

            PushButton moveY = moveWallItem.AddPushButton(new PushButtonData("YDirection", "Y Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.YMoveWalls"));
            moveY.ToolTip    = "move all walls 10 feet in Y direction.";
            moveY.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsYLarge.png"), UriKind.Absolute));
            #endregion

            ribbonSamplePanel.AddSeparator();

            application.ControlledApplication.DocumentCreated += new EventHandler <Autodesk.Revit.DB.Events.DocumentCreatedEventArgs>(DocumentCreated);
        }
示例#57
0
        public Toolbox(ToolboxService toolboxService, IPadWindow container)
        {
            this.toolboxService = toolboxService;
            this.container      = container;

            #region Toolbar
            DockItemToolbar toolbar = container.GetToolbar(PositionType.Top);

            filterEntry              = new SearchEntry();
            filterEntry.Ready        = true;
            filterEntry.HasFrame     = true;
            filterEntry.WidthRequest = 150;
            filterEntry.Changed     += new EventHandler(filterTextChanged);
            filterEntry.Show();

            toolbar.Add(filterEntry, true);

            catToggleButton             = new ToggleButton();
            catToggleButton.Image       = new Image(Ide.Gui.Stock.GroupByCategory, IconSize.Menu);
            catToggleButton.Toggled    += new EventHandler(toggleCategorisation);
            catToggleButton.TooltipText = GettextCatalog.GetString("Show categories");
            toolbar.Add(catToggleButton);

            compactModeToggleButton             = new ToggleButton();
            compactModeToggleButton.Image       = new ImageView(ImageService.GetIcon("md-compact-display", IconSize.Menu));
            compactModeToggleButton.Toggled    += new EventHandler(ToggleCompactMode);
            compactModeToggleButton.TooltipText = GettextCatalog.GetString("Use compact display");
            toolbar.Add(compactModeToggleButton);

            toolboxAddButton = new Button(new Gtk.Image(Ide.Gui.Stock.Add, IconSize.Menu));
            toolbar.Add(toolboxAddButton);
            toolboxAddButton.TooltipText = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Clicked    += new EventHandler(toolboxAddButton_Clicked);
            toolbar.ShowAll();

            #endregion

            toolboxWidget = new ToolboxWidget();
            toolboxWidget.SelectedItemChanged += delegate {
                selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
                toolboxService.SelectItem(selectedNode);
            };
            this.toolboxWidget.DragBegin += delegate(object sender, Gtk.DragBeginArgs e) {
                if (this.toolboxWidget.SelectedItem != null)
                {
                    this.toolboxWidget.HideTooltipWindow();
                    toolboxService.DragSelectedItem(this.toolboxWidget, e.Context);
                }
            };
            this.toolboxWidget.ActivateSelectedItem += delegate {
                toolboxService.UseSelectedItem();
            };

            fontChanger = new MonoDevelop.Ide.Gui.PadFontChanger(toolboxWidget, toolboxWidget.SetCustomFont, toolboxWidget.QueueResize);

            this.toolboxWidget.DoPopupMenu = ShowPopup;

            scrolledWindow = new MonoDevelop.Components.CompactScrolledWindow();
            base.PackEnd(scrolledWindow, true, true, 0);
            base.FocusChain = new Gtk.Widget [] { scrolledWindow };

            //Initialise self
            scrolledWindow.ShadowType       = ShadowType.None;
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest     = 150;
            scrolledWindow.Add(this.toolboxWidget);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += delegate { Refresh(); };
            toolboxService.ToolboxConsumerChanged += delegate { Refresh(); };
            Refresh();

            //set initial state
            this.toolboxWidget.ShowCategories = catToggleButton.Active = true;
            compactModeToggleButton.Active    = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            this.toolboxWidget.IsListMode     = !compactModeToggleButton.Active;
            this.ShowAll();
        }
示例#58
0
        /// <summary>
        /// Creates a new <see cref="ColorButton"/> instance.
        /// </summary>
        public ColorButton()
        {
            SetStyles();

            ContentButton = new ToggleButton();

            ContentButton.Classes.Add("ContentButton");
            ContentButton.Padding = new Thickness(4, 4, 0, 4);

            Grid mainGrid = new Grid();

            ContentButton.Content = mainGrid;

            mainGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
            mainGrid.ColumnDefinitions.Add(new ColumnDefinition(16, GridUnitType.Pixel));

            Border colorBorder = new Border()
            {
                MinHeight = 16, MinWidth = 24, BorderThickness = new Avalonia.Thickness(1), BorderBrush = (IBrush)Application.Current.FindResource("ThemeForegroundBrush"), HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Stretch, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Stretch
            };

            mainGrid.Children.Add(colorBorder);

            ColorBrush = new ColorVisualBrush(Color);

            colorBorder.Background = ColorBrush;

            Canvas arrowCanvas = new Canvas()
            {
                Width = 16, Height = 16
            };

            arrowCanvas.Classes.Add("ArrowCanvas");
            Grid.SetColumn(arrowCanvas, 1);

            PathGeometry arrowGeometry = new PathGeometry();
            PathFigure   arrowFigure   = new PathFigure()
            {
                StartPoint = new Avalonia.Point(4, 6), IsClosed = true, IsFilled = true
            };

            arrowFigure.Segments.Add(new LineSegment()
            {
                Point = new Avalonia.Point(8, 10)
            });
            arrowFigure.Segments.Add(new LineSegment()
            {
                Point = new Avalonia.Point(12, 6)
            });
            arrowGeometry.Figures.Add(arrowFigure);
            Path arrowPath = new Path()
            {
                Data = arrowGeometry
            };

            arrowCanvas.Children.Add(arrowPath);
            mainGrid.Children.Add(arrowCanvas);

            arrowCanvas.RenderTransformOrigin = new RelativePoint(0.5, 0.5, RelativeUnit.Relative);

            Popup palettePopup = new Popup
            {
                PlacementMode    = PlacementMode.AnchorAndGravity,
                PlacementGravity = Avalonia.Controls.Primitives.PopupPositioning.PopupGravity.Bottom,
                PlacementAnchor  = Avalonia.Controls.Primitives.PopupPositioning.PopupAnchor.Bottom,
                PlacementConstraintAdjustment = Avalonia.Controls.Primitives.PopupPositioning.PopupPositionerConstraintAdjustment.FlipY,
                PlacementTarget = ContentButton
            };

            mainGrid.Children.Add(palettePopup);

            Border paletteBorder = new Border()
            {
                BorderThickness = new Thickness(1), BorderBrush = (IBrush)Application.Current.FindResource("ThemeBorderLowBrush")
            };

            palettePopup.Child = paletteBorder;

            Grid paletteGrid = new Grid()
            {
                Margin = new Thickness(5)
            };

            paletteGrid.RowDefinitions.Add(new RowDefinition(0, GridUnitType.Auto));
            paletteGrid.RowDefinitions.Add(new RowDefinition(0, GridUnitType.Auto));

            Button openColorPickerButton = new Button()
            {
                Content = "More colours..."
            };

            Grid.SetRow(openColorPickerButton, 1);
            paletteGrid.Children.Add(openColorPickerButton);

            PaletteContainer = new Grid()
            {
                Margin = new Thickness(0, 0, 0, 5)
            };

            paletteGrid.Children.Add(PaletteContainer);

            openColorPickerButton.Click += async(s, e) =>
            {
                palettePopup.Close();
                ColorPickerWindow win    = new ColorPickerWindow(Color);
                Color?            newCol = await win.ShowDialog(this.FindLogicalAncestorOfType <Window>());

                if (newCol != null)
                {
                    this.Color = newCol.Value;
                }
                ContentButton.IsChecked = false;
            };

            paletteBorder.Child = paletteGrid;

            ContentButton.PropertyChanged += async(s, e) =>
            {
                if (e.Property == ToggleButton.IsCheckedProperty)
                {
                    if ((e.NewValue as bool?).Value == true)
                    {
                        if (Palette.CurrentPalette != null && Palette.CurrentPalette.Colors.Count > 0)
                        {
                            PaletteContainer.Children.Clear();
                            PaletteContainer.Children.Add(GetPaletteCanvas(Palette.CurrentPalette));
                            palettePopup.Open();
                        }
                        else
                        {
                            ColorPickerWindow win    = new ColorPickerWindow(Color);
                            Color?            newCol = await win.ShowDialog(this.FindLogicalAncestorOfType <Window>());

                            if (newCol != null)
                            {
                                this.Color = newCol.Value;
                            }
                            ContentButton.IsChecked = false;
                        }
                    }
                    else
                    {
                        palettePopup.Close();
                    }
                }
            };

            this.Content = ContentButton;
        }
示例#59
0
        /// <summary>
        /// 切换功能区按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FuncationToggleButton_Checked(object sender, RoutedEventArgs e)
        {
            ClearMainWindow();
            ToggleButton tb = sender as ToggleButton;

            tb.IsEnabled = false;
            tb.IsChecked = true;
            switch (tb.Tag.ToString())
            {
            case "0":
                ChannelManagePolyline.Visibility = Visibility.Visible;

                moduleChannel.MainMap.Points =
                    BrushAnchor.BrushCameraForChannel(
                        channel: GlobalCache.ChannelList,
                        blueCamera: PathOfImage.BlueCamera,
                        redCamera: PathOfImage.RedCamere);

                if (moduleChannel.MainMap.Points.Count > 0)
                {
                    moduleChannel.MainMap.CurrentPosition = moduleChannel.MainMap.Points[moduleChannel.MainMap.Points.Count - 1].Point;
                }
                else
                {
                    moduleChannel.MainMap.CurrentPosition = new GMap.NET.PointLatLng(GlobalCache.Latitude, GlobalCache.Longitude);
                }

                FuncationArea.Content = moduleChannel;
                //增加地图锚点显示功能
                break;

            case "1":
                CompOfRecordsPolyline.Visibility = Visibility.Visible;
                moduleCompare.RefreshChannelComboBox();
                FuncationArea.Content = moduleCompare;
                break;

            case "2":
                CaptureRecordQueryPolyline.Visibility = Visibility.Visible;
                moduleSnap.RefreshChannelComboBox();
                FuncationArea.Content = moduleSnap;
                break;

            case "3":
                TemplateManagerPolyline.Visibility      = Visibility.Visible;
                moduleTemplate.QueryTemplateCmpDelegate = TMQueryTemplateCmp;
                FuncationArea.Content = moduleTemplate;
                break;

            case "4":
                StaticComparePolyline.Visibility = Visibility.Visible;
                sc.MainControl staticAnalysis = new sc.MainControl();
                FuncationArea.Content = staticAnalysis;
                break;

            case "5":
                LocusAnalyzePolyline.Visibility = Visibility.Visible;
                tr.MainTraceAnalysisView traceAnalysis = new tr.MainTraceAnalysisView();
                if (!(e.Source is ToggleButton))
                {
                    traceAnalysis.GetPersonInfo(e.Source);
                }
                FuncationArea.Content = traceAnalysis;
                break;

            case "6":
                BusinessIntelligentPolyline.Visibility = Visibility.Visible;
                bi.MainControl businessIntelligate = new bi.MainControl();
                if (!(e.Source is ToggleButton))
                {
                    biviewmodel.MainControlViewModel.ReceivedObj = e.Source;
                }
                FuncationArea.Content = businessIntelligate;
                break;
            }
        }
示例#60
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.button   = (ToggleButton)this.GetTemplateChild("PART_ToggleDropDown");
            this.popup    = (Popup)this.GetTemplateChild("PART_Popup");
            this.content  = (ContentControl)this.GetTemplateChild("PART_Content");
            this.dragGrip = (FrameworkElement)this.GetTemplateChild("PART_DragGrip");

            if (this.popup != null)
            {
                this.popup.Opened += (sender, args) =>
                {
                    if (this.PopupOpened != null)
                    {
                        this.PopupOpened(sender, args);
                    }
                };
            }

            if (this.content != null)
            {
                this.content.LayoutUpdated += (sender, args) =>
                {
                    if (this.ContentLayoutUpdated != null)
                    {
                        this.ContentLayoutUpdated(this.content, args);
                    }
                };
            }

            this.SizeChanged += this.DropDownButton_SizeChanged;
            if (this.dragGrip != null)
            {
                this.dragGrip.MouseLeftButtonDown += this.dragGrip_MouseLeftButtonDown;
                this.dragGrip.MouseMove           += this.dragGrip_MouseMove;
                this.dragGrip.MouseLeftButtonUp   += this.dragGrip_MouseLeftButtonUp;
            }

#if (SILVERLIGHT)
            UIElement root = Application.Current.RootVisual;
            if (root != null)
            {
                root.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnRootMouseLeftButtonDown), true);
            }
#endif

#if (!SILVERLIGHT)
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                System.Windows.Window window = System.Windows.Window.GetWindow(this);
                window.LocationChanged += window_LocationChanged;
                window.SizeChanged     += window_SizeChanged;
                window.Deactivated     += window_Deactivated;
                window.Activated       += window_Activated;
                LayoutUpdated          += DropDownButton_LayoutUpdated;
            }

            popup.Opened += popup_Opened;
            Window.GetWindow(this).AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(Outside_MouseDown), true);
            Window.GetWindow(this).Activated += window_Activated;
#endif
        }