/// <summary>Click event handler of the Target Delete button.</summary> /// <param name="sender">Sender Object.</param> /// <param name="e">Event parameters.</param> private void btnTargetDelete_Click(object sender, RoutedEventArgs e) { int selIdx = lstTargets.SelectedIndex; if (selIdx < 0) { return; } RssTargetInfo info = (RssTargetInfo)_rssTargets[selIdx]; System.Windows.Forms.DialogResult ret = System.Windows.Forms.MessageBox.Show( "\"" + info.Title + "\"" + Properties.Resources.CONFIRM_DELETE, this.Title, System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question ); if (ret == System.Windows.Forms.DialogResult.OK) { if (info.CurPath != null) { _deletedRssInfos.Add(info); } _rssTargets.RemoveAt(selIdx); for (int i = selIdx; i < _rssTargets.Count; i++) { ((RssTargetInfo)_rssTargets[i]).Idx = i; } lstTargets.Items.RemoveAt(selIdx); _targetsModified = true; } }
/// <summary>Click event handler of the OK button.</summary> /// <param name="sender">Sender Object.</param> /// <param name="e">Event parameters.</param> private void btnOK_Click(object sender, RoutedEventArgs e) { RssTargetInfo rssInfo = _CheckParams(); if (rssInfo != null) { rssInfo.Idx = _infoIdx; ((WndSettings)Owner).UpdateTargetList(rssInfo); this.Close(); } }
private void _AddTrashBox(RssTargetInfo targetInfo) { TrashBox trashBox = targetInfo.TrashBox; _trashBoxes.Add(trashBox); TreeViewImgItem targetNode = new TreeViewImgItem(TRASH_NODE_TARGET); targetNode.Text = targetInfo.Title; targetNode.SelectedImage = (targetInfo.IsZeptDist) ? _zeptairIcon : _feedIcon; targetNode.IsExpanded = true; ArrayList channels = new ArrayList(); foreach (InfoItem infoItem in trashBox.InfoItems) { if (!channels.Contains(infoItem.Channel)) { channels.Add(infoItem.Channel); } } Hashtable channelHash = new Hashtable(); foreach (string channel in channels) { TreeViewImgItem channelNode = new TreeViewImgItem(TRASH_NODE_CHANNEL); channelNode.Text = channel; channelNode.SelectedImage = _channelIcon; channelNode.IsExpanded = false; channelHash[channel] = channelNode; targetNode.Items.Add(channelNode); } foreach (InfoItem infoItem in trashBox.InfoItems) { TreeViewImgItem itemNode = new TreeViewImgItem(TRASH_NODE_ITEM); itemNode.Text = infoItem.Title; itemNode.SelectedImage = _itemIcon; itemNode.AdditionalInfo = infoItem; ((TreeViewImgItem)channelHash[infoItem.Channel]).Items.Add(itemNode); } trvTrash.Items.Add(targetNode); }
/// <summary>Updates or adds the specified item in the Target List.</summary> /// <param name="info">New RSS Information.</param> public void UpdateTargetList(RssTargetInfo info) { ArrayList targetList = null; System.Windows.Controls.ListBox listBox = null; BitmapImage icon = null; if (info.IsZeptDist) { #if ZEPTAIR targetList = _zeptDistTargets; listBox = lstZeptDists; icon = _zeptairIcon; #endif } else { targetList = _rssTargets; listBox = lstTargets; icon = _feedIcon; } if (info.Idx < 0) { info.Idx = targetList.Count; targetList.Add(info); ListViewImgItem targetNode = new ListViewImgItem(); targetNode.Text = info.Title; targetNode.SelectedImage = icon; listBox.Items.Add(targetNode); } else { targetList[info.Idx] = info; ((ListViewImgItem)listBox.Items[info.Idx]).Text = info.Title; } _targetsModified = true; }
/// <summary>Constructor (For Edit).</summary> /// <param name="info">Target RSS Information.</param> public WndTarget(RssTargetInfo info) { InitializeComponent(); _infoIdx = info.Idx; _isZeptDist = info.IsZeptDist; tbxTitle.Text = info.Title; tbxUrl.Text = info.Url; if (info.UserName != null && info.UserName.Length > 0) { chkAuth.IsChecked = true; tbxUserName.Text = info.UserName; tbxPassword.Password = info.Password; } else { grdAuth.Visibility = Visibility.Hidden; grdAuth.Height = 0; } scbInterval.Minimum = RssTargetInfo.POLLING_INTERVAL_MIN; scbInterval.Value = info.PollingInterval; }
/// <summary>Constructor.</summary> public WndSettings() { InitializeComponent(); _CheckProcessDuplicated(); _configManager = ConfigManager.Load(); _confConfig = ConfConfig.Load(); Width = _confConfig.SettingsWidth; Height = _confConfig.SettingsHeight; txbConfigMaxPanels.Text = _configManager.MaxItemsOnPanel.ToString(); _feedIcon = WpfUtil.LoadImage(FEED_ICON_URI); _zeptairIcon = WpfUtil.LoadImage(ZEPTAIR_ICON_URI); _channelIcon = WpfUtil.LoadImage(CHANNEL_ICON_URI); _itemIcon = WpfUtil.LoadImage(ITEM_ICON_URI); // Target Information ArrayList targetInfos = RssTargetInfo.Load(); _rssTargets = new ArrayList(); _zeptDistTargets = new ArrayList(); if (targetInfos != null) { foreach (RssTargetInfo info in targetInfos) { ListViewImgItem targetNode = new ListViewImgItem(); targetNode.Text = info.Title; if (info.IsZeptDist) { #if ZEPTAIR targetNode.SelectedImage = _zeptairIcon; lstZeptDists.Items.Add(targetNode); _zeptDistTargets.Add(info); #endif } else { targetNode.SelectedImage = _feedIcon; lstTargets.Items.Add(targetNode); _rssTargets.Add(info); } } } #if ZEPTAIR _UpdateZeptDistAddButton(); #endif // Trash Box _trashBoxes = new ArrayList(); foreach (RssTargetInfo targetInfo in _rssTargets) { _AddTrashBox(targetInfo); } foreach (RssTargetInfo targetInfo in _zeptDistTargets) { _AddTrashBox(targetInfo); } App curApp = (App)System.Windows.Application.Current; #if ZEPTAIR if (curApp.NeedLicKey) { txbNeedLicKey.Visibility = System.Windows.Visibility.Visible; } else { txbNeedLicKey.Visibility = System.Windows.Visibility.Hidden; } #endif // IPC RemotingConfiguration.Configure(Path.Combine(ThetisCore.Lib.Def.COMMON_CONFIG_ROOT_DIR, @"remotingConf.config"), false); IpcConfService ipcConfService = new IpcConfService(); ipcConfService.TaskProcClosing += ipcConfService_TaskProcClosing; RemotingServices.Marshal(ipcConfService, "ipcConfService"); }
/// <summary>Checks if the specified parameters are valid and acceptable.</summary> /// <returns>A RSS Information instance if the parameters are valid, null otherwise.</returns> private RssTargetInfo _CheckParams() { WndSettings wndSettings = (WndSettings)this.Owner; RssTargetInfo info = null; ArrayList targetList = null; if (_isZeptDist) { targetList = wndSettings.ZeptDistTargetInfos; } else { targetList = wndSettings.RssTargetInfos; } if (_infoIdx < 0) { info = new RssTargetInfo(); info.IsZeptDist = _isZeptDist; } else { info = (RssTargetInfo)targetList[_infoIdx]; } info.Title = tbxTitle.Text; if (info.Title.Length <= 0) { System.Windows.Forms.MessageBox.Show( Properties.Resources.SPECIFY_SETTINGS_TITLE, this.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); return(null); } if (_infoIdx >= 0) { int idx = 0; foreach (RssTargetInfo targetInfo in targetList) { if (_infoIdx != idx && info.Title == targetInfo.Title) { System.Windows.Forms.MessageBox.Show( Properties.Resources.TITLE_EXISTS, this.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); return(null); } idx++; } } info.Url = tbxUrl.Text; if (info.Url.Length <= 0) { System.Windows.Forms.MessageBox.Show( Properties.Resources.SPECIFY_URL, this.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); return(null); } if (((bool)chkAuth.IsChecked) && tbxUserName.Text.Length <= 0) { System.Windows.Forms.MessageBox.Show( Properties.Resources.SPECIFY_USER_NAME, this.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); return(null); } if ((bool)chkAuth.IsChecked) { info.SetAuth(tbxUserName.Text, tbxPassword.Password); } int interval = 0; try { interval = Int32.Parse(tbxInterval.Text); } catch (Exception) {} info.PollingInterval = interval; if (info.PollingInterval < RssTargetInfo.POLLING_INTERVAL_MIN) { System.Windows.Forms.MessageBox.Show( Properties.Resources.ERROR_INVAID_INTERVAL, this.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); return(null); } return(info); }