|
From: <che...@us...> - 2007-04-09 03:04:27
|
Revision: 298
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=298&view=rev
Author: chef_koch
Date: 2007-04-08 20:03:35 -0700 (Sun, 08 Apr 2007)
Log Message:
-----------
fixed importing first line of FritzBoxMonitors export-file
added message box with import result
Modified Paths:
--------------
trunk/plugins/FritzBox/FritzBox.cs
trunk/plugins/FritzBox/FritzBoxSetupFrom.cs
Modified: trunk/plugins/FritzBox/FritzBox.cs
===================================================================
--- trunk/plugins/FritzBox/FritzBox.cs 2007-04-08 17:34:44 UTC (rev 297)
+++ trunk/plugins/FritzBox/FritzBox.cs 2007-04-09 03:03:35 UTC (rev 298)
@@ -242,10 +242,12 @@
}
}
- public static void ImportFritzBoxMonitor(string filepath)
+ public static int ImportFritzBoxMonitor(string filepath)
{
try
{
+ int count = 0;
+
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader(filepath))
@@ -260,18 +262,25 @@
Caller caller = new Caller();
caller.ID = ar[2];
- caller.Name = String.Format("{0} {1}", ar[0], ar[1]);
+ caller.Name = string.Format("{0} {1}", ar[0], ar[1]);
+ caller.Name = caller.Name.Trim();
caller.Show = true;
- if (!CallerExists(caller))
- phonebook.Add(caller);
+ if (CallerExists(caller)) continue;
+ if (caller.ID == "Telefonnummer") continue;
+
+ phonebook.Add(caller);
+ count++;
}
}
+
+ return count;
}
catch (Exception e)
{
// Let the user know what went wrong.
Log.Error("The file could not be read: {0}", e.Message);
+ return 0;
}
}
Modified: trunk/plugins/FritzBox/FritzBoxSetupFrom.cs
===================================================================
--- trunk/plugins/FritzBox/FritzBoxSetupFrom.cs 2007-04-08 17:34:44 UTC (rev 297)
+++ trunk/plugins/FritzBox/FritzBoxSetupFrom.cs 2007-04-09 03:03:35 UTC (rev 298)
@@ -144,6 +144,7 @@
this.labelHelp = new MediaPortal.UserInterface.Controls.MPLabel();
this.tabIncoming = new System.Windows.Forms.TabPage();
this.groupBoxPhonebook = new MediaPortal.UserInterface.Controls.MPGroupBox();
+ this.mpImportFBMonitor = new MediaPortal.UserInterface.Controls.MPButton();
this.checkBoxSaveUnknownCaller = new MediaPortal.UserInterface.Controls.MPCheckBox();
this.checkBoxShowUnknownCaller = new MediaPortal.UserInterface.Controls.MPCheckBox();
this.checkBoxUsePhonebook = new MediaPortal.UserInterface.Controls.MPCheckBox();
@@ -174,7 +175,6 @@
this.buttonCancel = new MediaPortal.UserInterface.Controls.MPButton();
this.buttonSave = new MediaPortal.UserInterface.Controls.MPButton();
this.labelVersion = new MediaPortal.UserInterface.Controls.MPLabel();
- this.mpImportFBMonitor = new MediaPortal.UserInterface.Controls.MPButton();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.tabControlFritzBoxSettings.SuspendLayout();
this.tabGeneral.SuspendLayout();
@@ -344,6 +344,17 @@
this.groupBoxPhonebook.TabStop = false;
this.groupBoxPhonebook.Text = "phonebook settings";
//
+ // mpImportFBMonitor
+ //
+ this.mpImportFBMonitor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.mpImportFBMonitor.Location = new System.Drawing.Point(355, 20);
+ this.mpImportFBMonitor.Name = "mpImportFBMonitor";
+ this.mpImportFBMonitor.Size = new System.Drawing.Size(150, 23);
+ this.mpImportFBMonitor.TabIndex = 3;
+ this.mpImportFBMonitor.Text = "Import FRITZ!Box Monitor";
+ this.mpImportFBMonitor.UseVisualStyleBackColor = true;
+ this.mpImportFBMonitor.Click += new System.EventHandler(this.mpImportFBMonitor_Click);
+ //
// checkBoxSaveUnknownCaller
//
this.checkBoxSaveUnknownCaller.AutoSize = true;
@@ -626,6 +637,7 @@
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(405, 297);
this.dataGridView.TabIndex = 5;
+ this.dataGridView.Sorted += new System.EventHandler(this.dataGridView_Sorted);
this.dataGridView.SelectionChanged += new System.EventHandler(this.dataGridView_SelectionChanged);
//
// colCallerId
@@ -700,17 +712,6 @@
this.labelVersion.TabIndex = 13;
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
- // mpImportFBMonitor
- //
- this.mpImportFBMonitor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.mpImportFBMonitor.Location = new System.Drawing.Point(355, 20);
- this.mpImportFBMonitor.Name = "mpImportFBMonitor";
- this.mpImportFBMonitor.Size = new System.Drawing.Size(150, 23);
- this.mpImportFBMonitor.TabIndex = 3;
- this.mpImportFBMonitor.Text = "Import FRITZ!Box Monitor";
- this.mpImportFBMonitor.UseVisualStyleBackColor = true;
- this.mpImportFBMonitor.Click += new System.EventHandler(this.mpImportFBMonitor_Click);
- //
// FritzBoxSetupForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
@@ -947,33 +948,39 @@
private void buttonCallerChange_Click(object sender, EventArgs e)
{
- if (CheckCallerId() && CheckCallerName())
- if (dataGridView.Rows[dataGridView.NewRowIndex].Selected)
- {
- dataGridView.Rows.Add(textBoxCallerId.Text, textBoxCallerName.Text, checkBoxCallerShow.Checked);
+ if (!CheckCallerId()) return;
+ if (!CheckCallerName()) return;
- textBoxCallerId.Text = "";
- textBoxCallerName.Text = "";
- checkBoxCallerShow.Checked = false;
+ if (dataGridView.Rows[dataGridView.NewRowIndex].Selected)
+ {
+ dataGridView.Rows.Add(textBoxCallerId.Text, textBoxCallerName.Text, checkBoxCallerShow.Checked);
- textBoxCallerId.Focus();
- }
- else
- {
- string oldfile = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac,
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[1].Value.ToString());
+ textBoxCallerId.Text = "";
+ textBoxCallerName.Text = "";
+ checkBoxCallerShow.Checked = false;
- string newfile = String.Format(@"{0}\{1}{2}", Thumbs.Yac, Utils.MakeFileName(textBoxCallerName.Text), Utils.GetThumbExtension());
+ textBoxCallerId.Focus();
- if (File.Exists(oldfile))
- File.Move(oldfile, newfile);
+ SaveDataGridView();
+ }
+ else
+ {
+ string oldfile = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac,
+ dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[1].Value.ToString());
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[0].Value = textBoxCallerId.Text;
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[1].Value = textBoxCallerName.Text;
- dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[2].Value = checkBoxCallerShow.Checked;
+ string newfile = String.Format(@"{0}\{1}{2}", Thumbs.Yac, Utils.MakeFileName(textBoxCallerName.Text), Utils.GetThumbExtension());
- pictureBoxCaller.ImageLocation = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, textBoxCallerName.Text);
- }
+ if (File.Exists(oldfile))
+ File.Move(oldfile, newfile);
+
+ dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[0].Value = textBoxCallerId.Text;
+ dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[1].Value = textBoxCallerName.Text;
+ dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells[2].Value = checkBoxCallerShow.Checked;
+
+ pictureBoxCaller.ImageLocation = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, textBoxCallerName.Text);
+
+ SaveDataGridView();
+ }
}
private bool CheckCallerId()
@@ -1014,6 +1021,8 @@
if ((!dataGridView.Rows[dataGridView.NewRowIndex].Selected) && (dataGridView.SelectedRows.Count > 0))
{
dataGridView.Rows.RemoveAt(dataGridView.CurrentCell.RowIndex);
+
+ SaveDataGridView();
}
}
@@ -1041,8 +1050,10 @@
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
- FritzBox.ImportFritzBoxMonitor(openFileDialog.FileName);
+ int count = FritzBox.ImportFritzBoxMonitor(openFileDialog.FileName);
RefreshDataGridView();
+
+ MessageBox.Show("Import done!\nAdded " + count.ToString() + " new CallerIDs to phonebook.");
}
}
@@ -1071,5 +1082,10 @@
FritzBox.phonebook.Add(caller);
}
}
+
+ private void dataGridView_Sorted(object sender, EventArgs e)
+ {
+ SaveDataGridView();
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|