예제 #1
0
        public AddComputer(DestinationBase db)
            : this()
        {
            this.dbEdit = db;
            if (db is Subscription) this.isSubscription = true;

            IDestinationHandler handler = null;
            if (isSubscription)
            {
                handler = SubscriptionManager.GetHandler(db);
            }
            else
            {
                handler = ForwardDestinationManager.GetHandler(db);
            }
            ShowInputs(null, handler);
        }
             ValidChanged(isValid);
         }
     }
 }
 public static IForwardDestinationHandler GetHandler(DestinationBase db)
 {
     Type type = db.GetType();
     return GetHandler(type);
 }
        void ForwardListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (this.View == View.Tile)
            {
                int checkBoxAreaWidth           = CHECKBOX_PADDING + CHECKBOX_SIZE + CHECKBOX_PADDING;
                System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(e.Bounds.X + checkBoxAreaWidth, e.Bounds.Top, e.Bounds.Width - checkBoxAreaWidth, e.Bounds.Height);

                // update information
                DestinationBase fc         = (DestinationBase)e.Item.Tag;
                string          display    = Escape(fc.Display);
                string          address    = Escape(fc.AddressDisplay);
                string          additional = Escape(fc.AdditionalDisplayInfo);
                string          tooltip    = String.Format("{0}\r\n{1}{2}", fc.Display, fc.AddressDisplay, (!String.IsNullOrEmpty(fc.AdditionalDisplayInfo) ? String.Format("\r\n{0}", fc.AdditionalDisplayInfo) : null));
                e.Item.ToolTipText = tooltip;
                // NOTE: dont set the .Text or .SubItem properties here - it causes an erratic exception

                bool drawEnabled = ShouldDrawEnabled(fc);
                bool selected    = this.SelectedIndices.Contains(e.ItemIndex);

                // draw the background for selected states
                if (drawEnabled && selected)
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                }
                else
                {
                    e.DrawBackground();
                }

                // draw the focus rectangle
                if (selected)
                {
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
                }

                // draw icon
                int             newX = bounds.X;
                DestinationBase db   = e.Item.Tag as DestinationBase;
                if (db != null)
                {
                    System.Drawing.Image img = db.GetIcon();

                    // size
                    if (img.Width > IMAGE_SIZE)
                    {
                        System.Drawing.Image    resized = new System.Drawing.Bitmap(IMAGE_SIZE, IMAGE_SIZE);
                        System.Drawing.Graphics g       = System.Drawing.Graphics.FromImage(resized);
                        using (g)
                        {
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                            g.DrawImage(img, 0, 0, IMAGE_SIZE, IMAGE_SIZE);
                        }
                        img = resized;
                    }

                    if (img != null)
                    {
                        int x = bounds.X;
                        int y = bounds.Top;
                        if (drawEnabled)
                        {
                            e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, img.Width, img.Height));
                        }
                        else
                        {
                            ControlPaint.DrawImageDisabled(e.Graphics, img, x, y, System.Drawing.Color.Transparent);
                        }
                        newX += IMAGE_SIZE + this.Margin.Right;
                    }
                }

                // offset the text vertically a bit so it lines up with the icon better
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, bounds.Top, bounds.Right - newX, e.Item.Font.Height);
                rect.Offset(0, 4);

                // draw main text
                System.Drawing.Color        textColor = (drawEnabled ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
                System.Drawing.StringFormat sf        = new System.Drawing.StringFormat();
                sf.Trimming    = System.Drawing.StringTrimming.EllipsisCharacter;
                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
                System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(textColor);
                using (textBrush)
                {
                    e.Graphics.DrawString(display,
                                          e.Item.Font,
                                          textBrush,
                                          rect,
                                          sf);
                }

                // draw additional information text
                System.Drawing.Color      subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
                using (subBrush)
                {
                    // draw address display (line 2)
                    rect.Offset(0, e.Item.Font.Height);
                    e.Graphics.DrawString(address,
                                          e.Item.Font,
                                          subBrush,
                                          rect,
                                          sf);

                    // draw additional display (line 3)
                    rect.Offset(0, e.Item.Font.Height);
                    e.Graphics.DrawString(additional,
                                          e.Item.Font,
                                          subBrush,
                                          rect,
                                          sf);
                }

                // draw checkbox
                System.Windows.Forms.VisualStyles.CheckBoxState state = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
                if (fc.Enabled)
                {
                    state = System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal;
                }
                else
                {
                    state = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
                }
                CheckBoxRenderer.DrawCheckBox(e.Graphics, new System.Drawing.Point(e.Bounds.Left + CHECKBOX_PADDING, e.Bounds.Top + CHECKBOX_PADDING), state);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
 /// <summary>
 /// Gets the settings panel associated with this forwarder.
 /// </summary>
 /// <param name="db">The <see cref="DestinationBase"/> of an exiting forwarder</param>
 /// <returns><see cref="DestinationSettingsPanel"/></returns>
 /// <remarks>
 /// This is called when a user is editing an existing forwarder.
 /// </remarks>
 public DestinationSettingsPanel GetSettingsPanel(DestinationBase db)
 {
     return(new XbmcInputs());
 }
예제 #7
0
 internal void Initialize(Controller controller, DestinationBase dbEdit, bool isSubscription)
 {
     this.controller = controller;
     this.dbEdit = dbEdit;
     this.isSubscription = isSubscription;
 }
 public Growl.Destinations.DestinationSettingsPanel GetSettingsPanel(DestinationBase db)
 {
     return new Growl.UI.TwitterForwardInputs();
 }
 public static ISubscriptionHandler GetHandler(DestinationBase db)
 {
     Type type = db.GetType();
     return GetHandler(type);
 }
        public override void Initialize(bool isSubscription, DestinationListItem fdli, DestinationBase fd)
        {
            this.doValidation = true;

            this.panelSMTPSettings.Visible = false;

            PrefPriority[] priorityChoices = PrefPriority.GetList(false);
            this.comboBoxMinimumPriority.Items.Add(Properties.Resources.AddProwl_AnyPriority);
            for (int i = 0; i < priorityChoices.Length; i++)
            {
                this.comboBoxMinimumPriority.Items.Add(priorityChoices[i]);
            }
            this.comboBoxMinimumPriority.SelectedIndex = 0;

            // set text box values
            this.textBoxDescription.Text               = String.Empty;
            this.textBoxDescription.Enabled            = true;
            this.textBoxUsername.Text                  = String.Empty;
            this.textBoxUsername.Enabled               = true;
            this.comboBoxMinimumPriority.SelectedIndex = 0;
            this.comboBoxMinimumPriority.Enabled       = true;

            EmailForwardDestination efd = fd as EmailForwardDestination;

            if (efd != null)
            {
                this.textBoxDescription.Text = efd.Description;
                this.textBoxUsername.Text    = efd.To;
                if (efd.MinimumPriority != null && efd.MinimumPriority.HasValue)
                {
                    this.comboBoxMinimumPriority.SelectedItem = PrefPriority.GetByValue(efd.MinimumPriority.Value);
                }
                this.checkBoxOnlyWhenIdle.Checked = efd.OnlyWhenIdle;
                this.smtp = efd.SMTPConfiguration;
            }
            this.labelSMTPValues.Text = String.Format("{0}", this.smtp.Host);

            ValidateInputs();

            this.textBoxDescription.Focus();
        }
        /// <summary>
        /// Initializes the configuration UI when a subscription is being added or edited.
        /// </summary>
        /// <param name="isSubscription">will always be <c>true</c> for <see cref="Subscription"/>s</param>
        /// <param name="dli">The <see cref="DestinationListItem"/> that the user selected</param>
        /// <param name="db">The <see cref="DestinationBase"/> of the item if it is being edited;<c>null</c> otherwise</param>
        /// <remarks>
        /// When an instance is being edited (<paramref name="dli"/> != null), make sure to repopulate any
        /// inputs with the current values.
        ///
        /// By default, the 'Save' button is disabled and you must call <see cref="DestinationSettingsPanel.OnValidChanged"/>
        /// in order to enable it when appropriate.
        /// </remarks>
        public override void Initialize(bool isSubscription, DestinationListItem fdli, DestinationBase db)
        {
            this.doValidation = true;

            // set text box values
            this.textBoxUrl.Text     = String.Empty;
            this.textBoxUrl.Enabled  = true;
            this.textBoxName.Text    = String.Empty;
            this.textBoxName.Enabled = true;

            this.comboBoxPoll.DataSource    = PollInterval.GetList();
            this.comboBoxPoll.DisplayMember = "Display";
            this.comboBoxPoll.ValueMember   = "Value";

            this.textBoxUsername.Text    = String.Empty;
            this.textBoxUsername.Enabled = true;
            this.textBoxPassword.Text    = String.Empty;
            this.textBoxPassword.Enabled = true;

            FeedSubscription fs = db as FeedSubscription;

            if (fs != null)
            {
                this.textBoxUrl.Text            = fs.FeedUrl;
                this.textBoxName.Text           = fs.Description;
                this.comboBoxPoll.SelectedValue = fs.PollInterval;
                this.textBoxUsername.Text       = fs.Username;
                this.textBoxPassword.Text       = fs.Password;
            }
            ValidateInputs();

            this.textBoxName.Focus();
        }
        public virtual void Update(DestinationBase db)

        {
            throw new NotImplementedException();
        }
        public virtual void Initialize(bool isSubscription, DestinationListItem fdli, DestinationBase db)

        {
            throw new NotImplementedException();
        }
예제 #14
0
        /// <summary>
        /// Initializes the configuration UI when a webhook is being added or edited.
        /// </summary>
        /// <param name="isSubscription">will always be <c>false</c> for <see cref="ForwardDestination"/>s</param>
        /// <param name="dli">The <see cref="DestinationListItem"/> that the user selected</param>
        /// <param name="db">The <see cref="DestinationBase"/> of the item if it is being edited;<c>null</c> otherwise</param>
        /// <remarks>
        /// When an instance is being edited (<paramref name="dli"/> != null), make sure to repopulate any
        /// inputs with the current values.
        ///
        /// By default, the 'Save' button is disabled and you must call <see cref="DestinationSettingsPanel.OnValidChanged"/>
        /// in order to enable it when appropriate.
        /// </remarks>
        public override void Initialize(bool isSubscription, DestinationListItem dli, DestinationBase db)
        {
            // set text box values
            this.textBoxName.Text    = String.Empty;
            this.textBoxName.Enabled = true;
            this.textBoxUrl.Text     = String.Empty;
            this.textBoxUrl.Enabled  = true;

            WebhookDestination whd = db as WebhookDestination;

            if (whd != null)
            {
                this.textBoxName.Text = whd.Description;
                this.textBoxUrl.Text  = whd.Url;
            }

            ValidateInputs();

            this.textBoxName.Focus();
        }
 public DestinationSettingsPanel GetSettingsPanel(DestinationBase db)
 {
     return(new FolderWatchSettings());
 }
예제 #16
0
        private void ChooseForwarding_Load(object sender, EventArgs e)
        {
            this.SuspendLayout();

            this.BackColor = Color.FromArgb(240, 240, 240);

            this.forwardListView1.AllDisabled = false;
            if (this.controller != null && this.prefs != null)
            {
                if (this.controller.ForwardDestinations != null && this.controller.ForwardDestinations.Count > 0)
                {
                    /*
                    Dictionary<string, DestinationBase> computers = new Dictionary<string, DestinationBase>();
                    foreach (ForwardDestination fc in this.controller.ForwardDestinations.Values)
                    {
                        bool enabled = this.prefs.PrefForwardCustomList.Contains(fc.Key);
                        DestinationBase clone = fc.Clone();
                        clone.Key = fc.Key;
                        clone.Enabled = enabled;
                        computers.Add(clone.Description, clone);
                    }
                    this.forwardListView1.Computers = computers;
                    this.forwardListView1.Draw();
                     * */

                    DestinationBase[] computers = new DestinationBase[this.controller.ForwardDestinations.Count];
                    int i = 0;
                    foreach (ForwardDestination fc in this.controller.ForwardDestinations.Values)
                    {
                        bool enabled = this.prefs.PrefForwardCustomList.Contains(fc.Key);
                        DestinationBase clone = fc.Clone();
                        clone.Key = fc.Key;
                        clone.Enabled = enabled;
                        computers[i++] = clone;
                    }
                    this.forwardListView1.Computers = computers;
                    this.forwardListView1.Draw();
                }
                else
                {
                    // need to show some kind of 'no computers available message'
                }
            }
            else
            {
                this.Close();
            }

            this.ResumeLayout();
        }
 public Growl.Destinations.DestinationSettingsPanel GetSettingsPanel(DestinationBase db)
 {
     return new Growl.UI.NotifyIOSubscriptionInputs();
 }
예제 #18
0
 /// <summary>
 /// Initializes the configuration UI when a subscription is being added or edited.
 /// </summary>
 /// <param name="isSubscription">will always be <c>true</c> for <see cref="Subscription"/>s</param>
 /// <param name="dli">The <see cref="DestinationListItem"/> that the user selected</param>
 /// <param name="db">The <see cref="DestinationBase"/> of the item if it is being edited;<c>null</c> otherwise</param>
 /// <remarks>
 /// When an instance is being edited (<paramref name="dli"/> != null), make sure to repopulate any
 /// inputs with the current values.
 ///
 /// By default, the 'Save' button is disabled and you must call <see cref="DestinationSettingsPanel.OnValidChanged"/>
 /// in order to enable it when appropriate.
 /// </remarks>
 public override void Initialize(bool isSubscription, DestinationListItem fdli, DestinationBase db)
 {
     OnValidChanged(true);
 }
예제 #19
0
 /// <summary>
 /// Updates the specified subscription instance.
 /// </summary>
 /// <param name="db">The <see cref="FeedSubscription"/> to update</param>
 /// <remarks>
 /// This is called when a user is editing an existing subscription and clicks the 'Save' button.
 /// </remarks>
 public override void Update(DestinationBase db)
 {
     // do nothing
 }
 public DestinationSettingsPanel GetSettingsPanel(DestinationBase db)
 {
     return new Growl.UI.ToastyForwardInputs();
 }
 public Growl.Destinations.DestinationSettingsPanel GetSettingsPanel(DestinationBase fd)
 {
     return new Growl.UI.ForwardDestinationInputs();
 }
        public override void Initialize(bool isSubscription, DestinationListItem fdli, DestinationBase fd)
        {
            this.doValidation   = true;
            this.isSubscription = isSubscription;

            this.comboBoxFormat.Items.Add(Properties.Resources.Protocol_Type_GNTP);
            this.comboBoxFormat.Items.Add(Properties.Resources.Protocol_Type_UDP);

            // set text box values
            BonjourListItem bli = fdli as BonjourListItem;

            if (bli != null)
            {
                this.isBonjour = true;
                DetectedService ds = bli.DetectedService;
                this.selectedService = ds;

                string host = ds.Hostname;
                int    port = ds.Service.Port;

                this.textBoxDescription.Text      = ds.Service.Name;
                this.textBoxDescription.Enabled   = false;
                this.textBoxAddress.Text          = host;
                this.textBoxAddress.Enabled       = false;
                this.textBoxPort.Text             = port.ToString();
                this.textBoxPort.Enabled          = false;
                this.comboBoxFormat.SelectedIndex = 0;
                this.comboBoxFormat.Enabled       = false;
                this.textBoxPassword.Focus();
            }
            else
            {
                this.textBoxDescription.Text      = String.Empty;
                this.textBoxDescription.Enabled   = true;
                this.textBoxAddress.Text          = String.Empty;
                this.textBoxAddress.Enabled       = true;
                this.textBoxPort.Text             = Growl.Connector.GrowlConnector.TCP_PORT.ToString();
                this.textBoxPort.Enabled          = true;
                this.comboBoxFormat.SelectedIndex = 0;
                this.comboBoxFormat.Enabled       = true;
                this.textBoxDescription.Focus();
            }

            // edits
            if (fd != null)
            {
                this.textBoxDescription.Text = fd.Description;
                this.comboBoxFormat.Enabled  = false;
                GNTPSubscription subscription = fd as GNTPSubscription;
                if (subscription != null)
                {
                    this.textBoxAddress.Text         = subscription.IPAddress;
                    this.textBoxPort.Text            = subscription.Port.ToString();
                    this.textBoxPassword.Text        = subscription.Password;
                    this.comboBoxFormat.SelectedItem = Properties.Resources.Protocol_Type_GNTP;
                    this.comboBoxFormat.Visible      = false;
                }
                GNTPForwardDestination gntp = fd as GNTPForwardDestination;
                if (gntp != null)
                {
                    this.textBoxAddress.Text         = gntp.IPAddress;
                    this.textBoxPort.Text            = gntp.Port.ToString();
                    this.textBoxPassword.Text        = gntp.Password;
                    this.comboBoxFormat.SelectedItem = Properties.Resources.Protocol_Type_GNTP;
                }
                BonjourForwardDestination bonjour = fd as BonjourForwardDestination;
                if (bonjour != null)
                {
                    this.textBoxAddress.Text         = bonjour.IPAddress;
                    this.textBoxPort.Text            = bonjour.Port.ToString();
                    this.textBoxPassword.Text        = bonjour.Password;
                    this.comboBoxFormat.SelectedItem = Properties.Resources.Protocol_Type_GNTP;
                    this.textBoxDescription.Enabled  = false;
                    this.textBoxAddress.Enabled      = false;
                    this.textBoxPort.Enabled         = false;
                    this.textBoxPassword.Focus();
                }
                UDPForwardDestination udp = fd as UDPForwardDestination;
                if (udp != null)
                {
                    this.textBoxAddress.Text         = udp.IPAddress;
                    this.textBoxPort.Text            = udp.Port.ToString();
                    this.textBoxPassword.Text        = udp.Password;
                    this.comboBoxFormat.SelectedItem = Properties.Resources.Protocol_Type_UDP;
                }
            }

            if (isSubscription)
            {
                this.labelFormat.Visible    = false;
                this.comboBoxFormat.Visible = false;
            }

            ValidateInputs();
        }