Beispiel #1
1
        public ConnectWindow()
        {
            InitializeComponent();

            try
            {
                IsAvailableServer = ServiceCtrlClass.ServiceIsInstalled("EpgTimer Service") == true ||
                    System.IO.File.Exists(SettingPath.ModulePath.TrimEnd('\\') + "\\EpgTimerSrv.exe") == true;

                btn_edit.Visibility = Visibility.Collapsed;

                ConnectionList = new ObservableCollection<NWPresetItem>(Settings.Instance.NWPreset);
                var nowSet = new NWPresetItem(DefPresetStr, Settings.Instance.NWServerIP, Settings.Instance.NWServerPort, Settings.Instance.NWWaitPort, Settings.Instance.NWMacAdd, Settings.Instance.NWPassword);
                int pos = ConnectionList.ToList().FindIndex(item => item.EqualsTo(nowSet, true));
                if (pos == -1)
                {
                    ConnectionList.Add(nowSet);
                    pos = ConnectionList.Count - 1;
                }
                if (IsAvailableServer == true)
                {
                    ConnectionList.Insert(0, new NWPresetItem("ローカル接続", "", 0, 0, "", new SerializableSecureString()));
                    pos++;
                }
                ConnectionList.Add(new NWPresetItem("<新規登録>", "", 0, 0, "", new SerializableSecureString()));

                listView_List.ItemsSource = ConnectionList;
                if (IsAvailableServer == false)
                {
                    Settings.Instance.NWMode = true;
                }
                listView_List.SelectedIndex = Settings.Instance.NWMode == true ? pos : 0;
            }
            catch { }
        }
Beispiel #2
0
 public bool EqualsTo(NWPresetItem item, bool ignoreName = false)
 {
     return((ignoreName == true || Name == item.Name) &&
            NWServerIP == item.NWServerIP && NWServerPort == item.NWServerPort &&
            NWWaitPort == item.NWWaitPort && NWMacAdd == item.NWMacAdd);
     /* パスワードは比べなくてもいいかな? */
 }
Beispiel #3
0
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            NWPresetItem newitem = GetSetting();

            if (newitem.NWServerIP.Length == 0)
            {
                MessageBox.Show("接続サーバーが指定されていません。");
            }
            else
            {
                int pos = ConnectionList.ToList().FindIndex(item => item.Name == newitem.Name);
                if (pos >= 0)
                {
                    MessageBox.Show("登録名が既に登録されています。");
                }
                else
                {
                    var olditem = listView_List.SelectedItem as NWPresetItem;
                    if (olditem != null && olditem.Name == DefPresetStr)
                    {
                        ConnectionList.RemoveAt(listView_List.SelectedIndex);
                    }
                    ConnectionList.Insert(ConnectionList.Count - 1, newitem);
                    UpdateNWPreset();
                    listView_List.SelectedIndex = ConnectionList.Count - 2;
                }
            }
        }
Beispiel #4
0
        public ConnectWindow()
        {
            InitializeComponent();

            try
            {
                IsAvailableServer = ServiceCtrlClass.ServiceIsInstalled("EpgTimer Service") == true ||
                                    System.IO.File.Exists(SettingPath.ModulePath.TrimEnd('\\') + "\\EpgTimerSrv.exe") == true;

                btn_edit.Visibility = Visibility.Collapsed;

                ConnectionList = new ObservableCollection <NWPresetItem>(Settings.Instance.NWPreset);
                var nowSet = new NWPresetItem(DefPresetStr, Settings.Instance.NWServerIP, Settings.Instance.NWServerPort, Settings.Instance.NWWaitPort, Settings.Instance.NWMacAdd, Settings.Instance.NWPassword);
                int pos    = ConnectionList.ToList().FindIndex(item => item.EqualsTo(nowSet, true));
                if (pos == -1)
                {
                    ConnectionList.Add(nowSet);
                    pos = ConnectionList.Count - 1;
                }
                if (IsAvailableServer == true)
                {
                    ConnectionList.Insert(0, new NWPresetItem("ローカル接続", "", 0, 0, "", new SerializableSecureString()));
                    pos++;
                }
                ConnectionList.Add(new NWPresetItem("<新規登録>", "", 0, 0, "", new SerializableSecureString()));

                listView_List.ItemsSource = ConnectionList;
                if (IsAvailableServer == false)
                {
                    Settings.Instance.NWMode = true;
                }
                listView_List.SelectedIndex = Settings.Instance.NWMode == true ? pos : 0;
            }
            catch { }
        }
Beispiel #5
0
 public bool EqualsTo(NWPresetItem item, bool ignoreName = false)
 {
     return (ignoreName == true || Name == item.Name)
         && NWServerIP == item.NWServerIP && NWServerPort == item.NWServerPort
         && NWWaitPort == item.NWWaitPort && NWMacAdd == item.NWMacAdd;
     /* パスワードは比べなくてもいいかな? */
 }
Beispiel #6
0
 protected static void CopyData(NWPresetItem src, NWPresetItem dest)
 {
     dest.Name = src.Name;
     dest.NWServerIP = src.NWServerIP;
     dest.NWServerPort = src.NWServerPort;
     dest.NWWaitPort = src.NWWaitPort;
     dest.NWMacAdd = src.NWMacAdd;
     dest.NWPassword = src.NWPassword;
 }
Beispiel #7
0
 protected static void CopyData(NWPresetItem src, NWPresetItem dest)
 {
     dest.Name         = src.Name;
     dest.NWServerIP   = src.NWServerIP;
     dest.NWServerPort = src.NWServerPort;
     dest.NWWaitPort   = src.NWWaitPort;
     dest.NWMacAdd     = src.NWMacAdd;
     dest.NWPassword   = src.NWPassword;
 }
Beispiel #8
0
        private void SaveLastConnect()
        {
            NWPresetItem data = GetSetting();

            Settings.Instance.NWServerIP   = data.NWServerIP;
            Settings.Instance.NWServerPort = data.NWServerPort;
            Settings.Instance.NWWaitPort   = data.NWWaitPort;
            Settings.Instance.NWMacAdd     = data.NWMacAdd;
        }
Beispiel #9
0
        private NWPresetItem GetSetting()
        {
            var preset = new NWPresetItem();

            preset.NWServerIP   = textBox_srvIP.Text;
            preset.NWServerPort = MenuUtil.MyToNumerical(textBox_srvPort, Convert.ToUInt32, Settings.Instance.NWServerPort);
            preset.NWWaitPort   = checkBox_clientPort.IsChecked == false ? 0 : MenuUtil.MyToNumerical(textBox_clientPort, Convert.ToUInt32, Settings.Instance.NWWaitPort);
            preset.NWMacAdd     = textBox_mac.Text;
            return(preset);
        }
Beispiel #10
0
 private void SetSetting(NWPresetItem data)
 {
     if (data != null)
     {
         textBox_srvIP.Text            = data.NWServerIP;
         textBox_srvPort.Text          = data.NWServerPort.ToString();
         checkBox_clientPort.IsChecked = data.NWWaitPort != 0;
         textBox_clientPort.Text       = data.NWWaitPort == 0 ? "4520" : data.NWWaitPort.ToString();
         textBox_mac.Text = data.NWMacAdd;
     }
 }
Beispiel #11
0
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            NWPresetItem newitem = GetSetting();
            int          pos     = ConnectionList.ToList().FindIndex(item => item.Name == newitem.Name);

            if (pos >= 0)
            {
                ConnectionList.RemoveAt(pos);
                UpdateNWPreset();
                listView_List.SelectedIndex = Math.Min(pos, ConnectionList.Count - 1);
            }
        }
Beispiel #12
0
        public ConnectWindow()
        {
            InitializeComponent();

            var nowSet = new NWPresetItem(DefPresetStr, Settings.Instance.NWServerIP, Settings.Instance.NWServerPort, Settings.Instance.NWWaitPort, Settings.Instance.NWMacAdd);

            cmb_preset.Items.Add(nowSet);
            Settings.Instance.NWPreset.ForEach(item => cmb_preset.Items.Add(item.DeepClone()));
            cmb_preset.SelectedIndex = FindCmbPresetItem(nowSet, true);
            this.KeyDown            += ViewUtil.KeyDown_Escape_Close;
            cmb_preset.KeyDown      += ViewUtil.KeyDown_Enter(btn_reload);
            button_connect.Focus();//スペースキーも効く
        }
Beispiel #13
0
 private void button_connect_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         NWPresetItem data = GetSetting();
         Settings.Instance.NWServerIP   = data.NWServerIP;
         Settings.Instance.NWServerPort = data.NWServerPort;
         Settings.Instance.NWWaitPort   = data.NWWaitPort;
         Settings.Instance.NWMacAdd     = data.NWMacAdd;
         DialogResult = true;
     }
     catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
     return;
 }
Beispiel #14
0
        private NWPresetItem GetSetting()
        {
            var preset = new NWPresetItem();

            preset.Name         = textBox_Name.Text.Trim();
            preset.NWServerIP   = textBox_srvIP.Text.Trim();
            preset.NWServerPort = MenuUtil.MyToNumerical(textBox_srvPort, Convert.ToUInt32, Settings.Instance.NWServerPort);
            preset.NWWaitPort   = checkBox_clientPort.IsChecked == false ? 0 : MenuUtil.MyToNumerical(textBox_clientPort, Convert.ToUInt32, Settings.Instance.NWWaitPort);
            preset.NWMacAdd     = textBox_mac.Text.Trim();
            preset.NWPassword   = new SerializableSecureString(textBox_Password.SecurePassword);
            if (preset.Name.Length == 0)
            {
                preset.Name = preset.NWServerIP;
            }
            return(preset);
        }
Beispiel #15
0
        private void btn_edit_Click(object sender, RoutedEventArgs e)
        {
            NWPresetItem newitem = GetSetting();
            int          pos     = listView_List.SelectedIndex;

            if (pos >= 0)
            {
                ConnectionList[pos] = newitem;
                int DefPresetPos = ConnectionList.ToList().FindIndex(item => item.Name == DefPresetStr);
                if (DefPresetPos >= 0 && ConnectionList[DefPresetPos].EqualsTo(newitem, true))
                {
                    ConnectionList.RemoveAt(DefPresetPos);
                }
                UpdateNWPreset();
                listView_List.SelectedIndex = pos;
            }
        }
Beispiel #16
0
 private void SetSetting(NWPresetItem data)
 {
     if (data != null)
     {
         textBox_Name.Text             = data.Name == DefPresetStr ? "" : data.Name;
         textBox_srvIP.Text            = data.NWServerIP;
         textBox_srvPort.Text          = data.NWServerPort.ToString();
         checkBox_clientPort.IsChecked = data.NWWaitPort != 0;
         textBox_clientPort.Text       = data.NWWaitPort == 0 ? "4520" : data.NWWaitPort.ToString();
         textBox_mac.Text          = data.NWMacAdd;
         textBox_Password.Password = new System.Net.NetworkCredential(string.Empty, data.NWPassword.SecureString).Password; // セキュアなコピーではない
     }
     else
     {
         textBox_Name.Text             = "";
         textBox_srvIP.Text            = "";
         textBox_srvPort.Text          = "";
         checkBox_clientPort.IsChecked = false;
         textBox_clientPort.Text       = "";
         textBox_mac.Text          = "";
         textBox_Password.Password = "";
     }
 }
Beispiel #17
0
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            if (IsCmbTextInvalid() == true)
            {
                return;                            //デフォルトアイテム
            }
            NWPresetItem newitem = GetSetting();

            newitem.Name = cmb_preset.Text.Trim();

            int pos = cmb_preset.SelectedIndex;

            if (pos >= 0)
            {
                cmb_preset.Items[pos]    = newitem;
                cmb_preset.SelectedIndex = pos;
            }
            else
            {
                cmb_preset.Items.Add(newitem);
                cmb_preset.SelectedIndex = cmb_preset.Items.Count - 1;
            }
        }
Beispiel #18
0
        private void DoConnect()
        {
            try
            {
                Settings.Instance.NWMode = IsAvailableServer == false || listView_List.SelectedIndex > 0;
                if (Settings.Instance.NWMode == true)
                {
                    NWPresetItem data = GetSetting();
                    Settings.Instance.NWServerIP   = data.NWServerIP;
                    Settings.Instance.NWServerPort = data.NWServerPort;
                    Settings.Instance.NWWaitPort   = data.NWWaitPort;
                    Settings.Instance.NWMacAdd     = data.NWMacAdd;
                    Settings.Instance.NWPassword   = data.NWPassword;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
                return;
            }

            DialogResult = true;
        }
Beispiel #19
0
 private void SetSetting(NWPresetItem data)
 {
     if (data != null)
     {
         textBox_Name.Text = data.Name == DefPresetStr ? "" : data.Name;
         textBox_srvIP.Text = data.NWServerIP;
         textBox_srvPort.Text = data.NWServerPort.ToString();
         checkBox_clientPort.IsChecked = data.NWWaitPort != 0;
         textBox_clientPort.Text = data.NWWaitPort == 0 ? "4520" : data.NWWaitPort.ToString();
         textBox_mac.Text = data.NWMacAdd;
         textBox_Password.Password = new System.Net.NetworkCredential(string.Empty, data.NWPassword.SecureString).Password; // セキュアなコピーではない
     }
     else
     {
         textBox_Name.Text = "";
         textBox_srvIP.Text = "";
         textBox_srvPort.Text = "";
         checkBox_clientPort.IsChecked = false;
         textBox_clientPort.Text = "";
         textBox_mac.Text = "";
         textBox_Password.Password = "";
     }
 }
Beispiel #20
0
 private NWPresetItem GetSetting()
 {
     var preset = new NWPresetItem();
     preset.Name = textBox_Name.Text.Trim();
     preset.NWServerIP = textBox_srvIP.Text.Trim();
     preset.NWServerPort = MenuUtil.MyToNumerical(textBox_srvPort, Convert.ToUInt32, Settings.Instance.NWServerPort);
     preset.NWWaitPort = checkBox_clientPort.IsChecked == false ? 0 : MenuUtil.MyToNumerical(textBox_clientPort, Convert.ToUInt32, Settings.Instance.NWWaitPort);
     preset.NWMacAdd = textBox_mac.Text.Trim();
     preset.NWPassword = new SerializableSecureString(textBox_Password.SecurePassword);
     if (preset.Name.Length == 0)
     {
         preset.Name = preset.NWServerIP;
     }
     return preset;
 }
Beispiel #21
0
 private int FindCmbPresetItem(NWPresetItem preset, bool ignoreName = true)
 {
     return(cmb_preset.Items.OfType <NWPresetItem>().ToList().FindLastIndex(item => item.EqualsTo(preset, ignoreName)));
 }