示例#1
0
        public void Initialize(EditSession session)
        {
            PropertyDescriptor prop = session.Property;

            if (!prop.PropertyType.IsEnum)
            {
                throw new ApplicationException("Flags editor does not support editing values of type " + prop.PropertyType);
            }

            Spacing  = 3;
            propType = prop.PropertyType;

            property = prop.Description;
            if (property == null || property.Length == 0)
            {
                property = prop.Name;
            }

            // For small enums, the editor is a list of checkboxes inside a frame
            // For large enums (>5), use a selector dialog.

            values = System.Enum.GetValues(prop.PropertyType);

            if (values.Length < 6)
            {
                Gtk.VBox vbox = new Gtk.VBox(true, 3);

                flags = new Hashtable();

                foreach (object value in values)
                {
                    Gtk.CheckButton check = new Gtk.CheckButton(value.ToString());
                    check.TooltipText = value.ToString();
                    ulong uintVal = Convert.ToUInt64(value);
                    flags[check]   = uintVal;
                    flags[uintVal] = check;

                    check.Toggled += FlagToggled;
                    vbox.PackStart(check, false, false, 0);
                }

                Gtk.Frame frame = new Gtk.Frame();
                frame.Add(vbox);
                frame.ShowAll();
                PackStart(frame, true, true, 0);
            }
            else
            {
                flagsLabel            = new Gtk.Entry();
                flagsLabel.IsEditable = false;
                flagsLabel.HasFrame   = false;
                flagsLabel.ShowAll();
                PackStart(flagsLabel, true, true, 0);

                Gtk.Button but = new Gtk.Button("...");
                but.Clicked += OnSelectFlags;
                but.ShowAll();
                PackStart(but, false, false, 0);
            }
        }
示例#2
0
文件: Flags.cs 项目: orf53975/stetic
        public void Initialize(PropertyDescriptor prop)
        {
            if (!prop.PropertyType.IsEnum)
            {
                throw new ApplicationException("Flags editor does not support editing values of type " + prop.PropertyType);
            }

            property = prop.Label;
            Spacing  = 3;

            // For small enums, the editor is a list of checkboxes inside a frame
            // For large enums (>5), use a selector dialog.

            enm = Registry.LookupEnum(prop.PropertyType.FullName);

            if (enm.Values.Length < 6)
            {
                Gtk.VBox vbox = new Gtk.VBox(true, 3);

                tips  = new Gtk.Tooltips();
                flags = new Hashtable();

                foreach (Enum value in enm.Values)
                {
                    EnumValue eval = enm[value];
                    if (eval.Label == "")
                    {
                        continue;
                    }

                    Gtk.CheckButton check = new Gtk.CheckButton(eval.Label);
                    tips.SetTip(check, eval.Description, eval.Description);
                    uint uintVal = (uint)(int)eval.Value;
                    flags[check]   = uintVal;
                    flags[uintVal] = check;

                    check.Toggled += FlagToggled;
                    vbox.PackStart(check, false, false, 0);
                }

                Gtk.Frame frame = new Gtk.Frame();
                frame.Add(vbox);
                frame.ShowAll();
                PackStart(frame, true, true, 0);
            }
            else
            {
                flagsLabel            = new Gtk.Entry();
                flagsLabel.IsEditable = false;
                flagsLabel.HasFrame   = false;
                flagsLabel.ShowAll();
                PackStart(flagsLabel, true, true, 0);

                Gtk.Button but = new Gtk.Button("...");
                but.Clicked += OnSelectFlags;
                but.ShowAll();
                PackStart(but, false, false, 0);
            }
        }
示例#3
0
        public void Initialize(EditSession session)
        {
            PropertyDescriptor prop = session.Property;

            if (!prop.PropertyType.IsEnum)
                throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);

            Spacing = 3;
            propType = prop.PropertyType;

            property = prop.Description;
            if (property == null || property.Length == 0)
                property = prop.Name;

            // For small enums, the editor is a list of checkboxes inside a frame
            // For large enums (>5), use a selector dialog.

            values = System.Enum.GetValues (prop.PropertyType);

            if (values.Length < 6)
            {
                Gtk.VBox vbox = new Gtk.VBox (true, 3);

                flags = new Hashtable ();

                foreach (object value in values) {
                    Gtk.CheckButton check = new Gtk.CheckButton (value.ToString ());
                    check.TooltipText = value.ToString ();
                    ulong uintVal = Convert.ToUInt64 (value);
                    flags[check] = uintVal;
                    flags[uintVal] = check;

                    check.Toggled += FlagToggled;
                    vbox.PackStart (check, false, false, 0);
                }

                Gtk.Frame frame = new Gtk.Frame ();
                frame.Add (vbox);
                frame.ShowAll ();
                PackStart (frame, true, true, 0);
            }
            else
            {
                flagsLabel = new Gtk.Entry ();
                flagsLabel.IsEditable = false;
                flagsLabel.HasFrame = false;
                flagsLabel.ShowAll ();
                PackStart (flagsLabel, true, true, 0);

                Gtk.Button but = new Gtk.Button ("...");
                but.Clicked += OnSelectFlags;
                but.ShowAll ();
                PackStart (but, false, false, 0);
            }
        }
示例#4
0
		private void AttachWidgets (TextView textView)
		{
			// This is really different from the C version, but the
			// C versions seems a little pointless.

			Button button = new Button ("Click Me");
			button.Clicked +=  new EventHandler(EasterEggCB);
			textView.AddChildAtAnchor (button, buttonAnchor);
			button.ShowAll ();

			ComboBox combo = ComboBox.NewText ();
			combo.AppendText ("Option 1");
			combo.AppendText ("Option 2");
			combo.AppendText ("Option 3");

 			textView.AddChildAtAnchor (combo, menuAnchor);

			HScale scale = new HScale (null);
			scale.SetRange (0,100);
			scale.SetSizeRequest (70, -1);
			textView.AddChildAtAnchor (scale, scaleAnchor);
			scale.ShowAll ();

			Gtk.Image image = Gtk.Image.LoadFromResource ("floppybuddy.gif");
			textView.AddChildAtAnchor (image, animationAnchor);
			image.ShowAll ();

			Entry entry = new Entry ();
			textView.AddChildAtAnchor (entry, entryAnchor);
			entry.ShowAll ();
		}
 public void UpdateiFolder(iFolderWeb ifolder)
 {
     this.ifolder = ifolder;
        if (ifolder.LastSyncTime == null || ifolder.LastSyncTime == "")
     LastSuccessfulSync.Text = Util.GS("N/A");
        else
     LastSuccessfulSync.Text = ifolder.LastSyncTime;
        FFSyncValue.Text = "0";
        int syncInterval = 0;
        if (ifolder.SyncInterval <= 0)
        {
     try
     {
      syncInterval = ifws.GetDefaultSyncInterval();
     }
     catch
     {}
        }
        else
        {
     syncInterval = ifolder.SyncInterval;
        }
        if (syncInterval > 0)
        {
     syncInterval = syncInterval / 60;
        }
        SyncIntervalValue.Text = syncInterval + " " + Util.GS("minute(s)");
        NameLabel.Markup = string.Format("<span weight=\"bold\">{0}</span>", ifolder.Name);
        OwnerLabel.Markup = string.Format("<span size=\"small\">{0}</span>", ifolder.Owner);
        LocationLabel.Markup = string.Format("<span size=\"small\">{0}</span>", ifolder.UnManagedPath);
        try
        {
     SyncSize ss = ifws.CalculateSyncSize(ifolder.ID);
     FFSyncValue.Text = string.Format("{0}", ss.SyncNodeCount);
        }
        catch(Exception e)
        {
     FFSyncValue.Text = Util.GS("N/A");
        }
        try
        {
     ds = ifws.GetiFolderDiskSpace(ifolder.ID);
        }
        catch(Exception e)
        {
     ds = null;
        }
        if(ifolder.CurrentUserID == ifolder.OwnerID)
        {
     if(LimitCheckButton == null)
     {
      LimitCheckButton =
       new CheckButton(Util.GS("Set _Quota:"));
      LimitCheckButton.Toggled +=
     new EventHandler(OnLimitSizeButton);
      diskTable.Attach(LimitCheckButton, 0,1,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitEntry = new Entry();
      LimitEntry.Changed +=
       new EventHandler(OnLimitChanged);
      LimitEntry.Activated +=
       new EventHandler(OnLimitEdited);
      LimitEntry.FocusOutEvent +=
       new FocusOutEventHandler(OnLimitFocusLost);
      LimitEntry.WidthChars = 6;
      LimitEntry.MaxLength = 10;
      LimitEntry.Layout.Alignment = Pango.Alignment.Left;
      diskTable.Attach(LimitEntry, 1,2,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitCheckButton.ShowAll();
      LimitEntry.ShowAll();
     }
     else
     {
      LimitCheckButton.Visible = true;
      LimitEntry.Visible = true;
     }
     if(LimitLabel != null)
     {
      LimitLabel.Visible = false;
      LimitValue.Visible = false;
     }
        }
        else
        {
     if(LimitLabel == null)
     {
      LimitLabel = new Label(Util.GS("Quota:"));
      LimitLabel.Xalign = 0;
      diskTable.Attach(LimitLabel, 0,1,1,2,
       AttachOptions.Expand | AttachOptions.Fill, 0,0,0);
      LimitValue = new Label("0");
      LimitValue.Xalign = 1;
      diskTable.Attach(LimitValue, 1,2,1,2,
       AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
      LimitLabel.ShowAll();
      LimitValue.ShowAll();
     }
     else
     {
      LimitLabel.Visible = true;
      LimitValue.Visible = true;
     }
     if(LimitCheckButton != null)
     {
      LimitCheckButton.Visible = false;
      LimitEntry.Visible = false;
     }
        }
        if(ds != null)
        {
     int tmpValue;
     if(ds.Limit == 0)
     {
      LimitUnit.Sensitive = false;
      AvailLabel.Sensitive = false;
      AvailValue.Sensitive = false;
      AvailUnit.Sensitive = false;
      DiskUsageBar.Sensitive = false;
      DiskUsageFrame.Sensitive = false;
      DiskUsageFullLabel.Sensitive = false;
      DiskUsageEmptyLabel.Sensitive = false;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = false;
       LimitEntry.Sensitive = false;
       LimitEntry.Text = "0";
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = false;
       LimitValue.Sensitive = false;
       LimitValue.Text = "0";
      }
      AvailValue.Text = "0";
     }
     else
     {
      LimitUnit.Sensitive = true;
      AvailLabel.Sensitive = true;
      AvailValue.Sensitive = true;
      AvailUnit.Sensitive = true;
      DiskUsageBar.Sensitive = true;
      DiskUsageFrame.Sensitive = true;
      DiskUsageFullLabel.Sensitive = true;
      DiskUsageEmptyLabel.Sensitive = true;
      if(LimitCheckButton != null)
      {
       LimitCheckButton.Active = true;
       LimitEntry.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitEntry.Text = string.Format("{0}", tmpValue);
      }
      if(LimitLabel != null)
      {
       LimitLabel.Sensitive = true;
       LimitValue.Sensitive = true;
       tmpValue = (int)(ds.Limit / (1024 * 1024));
       LimitValue.Text = string.Format("{0}", tmpValue);
      }
      tmpValue = (int)(ds.AvailableSpace / (1024 * 1024));
      AvailValue.Text = string.Format("{0}",tmpValue);
     }
     SetGraph(ds.UsedSpace, ds.Limit);
     if(ds.UsedSpace == 0)
     {
      UsedValue.Text = "0";
     }
     else
     {
      tmpValue = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
      UsedValue.Text = string.Format("{0}", tmpValue);
     }
        }
 }
示例#6
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
				
			property = prop.Label;
			Spacing = 3;

			// For small enums, the editor is a list of checkboxes inside a frame
			// For large enums (>5), use a selector dialog.

			enm = Registry.LookupEnum (prop.PropertyType.FullName);
			
			if (enm.Values.Length < 6) 
			{
				Gtk.VBox vbox = new Gtk.VBox (true, 3);

				flags = new Hashtable ();

				foreach (Enum value in enm.Values) {
					EnumValue eval = enm[value];
					if (eval.Label == "")
						continue;

					Gtk.CheckButton check = new Gtk.CheckButton (eval.Label);
					check.TooltipText = eval.Description;
					uint uintVal = (uint) Convert.ToInt32 (eval.Value);
					flags[check] = uintVal;
					flags[uintVal] = check;
					
					check.Toggled += FlagToggled;
					vbox.PackStart (check, false, false, 0);
				}

				Gtk.Frame frame = new Gtk.Frame ();
				frame.Add (vbox);
				frame.ShowAll ();
				PackStart (frame, true, true, 0);
			} 
			else 
			{
				flagsLabel = new Gtk.Entry ();
				flagsLabel.IsEditable = false;
				flagsLabel.HasFrame = false;
				flagsLabel.ShowAll ();
				PackStart (flagsLabel, true, true, 0);
				
				Gtk.Button but = new Gtk.Button ("...");
				but.Clicked += OnSelectFlags;
				but.ShowAll ();
				PackStart (but, false, false, 0);
			}
		}