private void BTemp_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { AddNewPanel addF = new AddNewPanel() { Owner = (MainWindow)Application.Current.MainWindow }; (addF.DataContext as AddNewPanelViewModel).name = ((Button)sender).Tag.ToString(); (addF.DataContext as AddNewPanelViewModel).path = InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Path"); (addF.DataContext as AddNewPanelViewModel).version = InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Version"); if (InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Update") != "Unknown") { (addF.DataContext as AddNewPanelViewModel).updateDate = DateTime.Parse(InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Update")); } (addF.DataContext as AddNewPanelViewModel).site = InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Site"); (addF.DataContext as AddNewPanelViewModel).tags = (InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Tags")).Split(new string[] { ";" }, StringSplitOptions.None); //(addF.DataContext as AddNewPanelViewModel).completed = bool.Parse(InI.panelsFile.Read(((Button)sender).Tag.ToString(), "Completed")); (addF.DataContext as AddNewPanelViewModel).imageSource = (((Button)sender).Content as Image).Source; (addF.DataContext as AddNewPanelViewModel).EditMode(); addF.ShowDialog(); if ((addF.DataContext as AddNewPanelViewModel).ok) { if (((Button)sender).Tag.ToString() != (addF.DataContext as AddNewPanelViewModel).name) { InI.panelsFile.DeleteSection(((Button)sender).Tag.ToString()); if ((addF.DataContext as AddNewPanelViewModel).image != null) { CreateNewImage(((Button)sender).Tag.ToString(), (addF.DataContext as AddNewPanelViewModel).name, (addF.DataContext as AddNewPanelViewModel).image); } else { CreateNewImage(((Button)sender).Tag.ToString(), (addF.DataContext as AddNewPanelViewModel).name, null); } } else { if ((addF.DataContext as AddNewPanelViewModel).image != null) { CreateNewImage(null, (addF.DataContext as AddNewPanelViewModel).name, (addF.DataContext as AddNewPanelViewModel).image); } } ((Button)sender).Tag = (addF.DataContext as AddNewPanelViewModel).name; InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Path", (addF.DataContext as AddNewPanelViewModel).path); InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Version", (addF.DataContext as AddNewPanelViewModel).version); if ((addF.DataContext as AddNewPanelViewModel).updateDate.ToShortDateString() != "1/1/0001") { InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Update", (addF.DataContext as AddNewPanelViewModel).updateDate.ToShortDateString()); } else { InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Update", "Unknown"); } InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Site", (addF.DataContext as AddNewPanelViewModel).site); //InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Completed", (addF.DataContext as AddNewPanelViewModel).completed.ToString()); InI.panelsFile.Write(((Button)sender).Tag.ToString(), "Tags", string.Join(";", (addF.DataContext as AddNewPanelViewModel).tags)); (((Button)sender).Content as Image).Source = (addF.DataContext as AddNewPanelViewModel).imageSource; ((((Button)sender).Parent as StackPanel).Children[1] as TextBlock).Text = (addF.DataContext as AddNewPanelViewModel).name; (((Button)sender).Parent as StackPanel).Tag = string.Join(";", (addF.DataContext as AddNewPanelViewModel).tags); ((Button)sender).Content = new Image() { Width = 160, Height = 90, Source = (addF as AddNewPanel).imagePB.Source }; foreach (var x in mPage.currentFilter) { if (x != null && !string.Join(";", (addF.DataContext as AddNewPanelViewModel).tags).Contains(x)) { ((((Button)sender).Parent as StackPanel).Parent as ListBoxItem).Visibility = Visibility.Collapsed; break; } } } }
private void AddNewPanel_Click() { AddNewPanel addF = new AddNewPanel() { Owner = (MainWindow)Application.Current.MainWindow }; addF.ShowDialog(); if ((addF.DataContext as AddNewPanelViewModel).ok && (addF.DataContext as AddNewPanelViewModel).image != null) { Visibility _visibility = Visibility.Visible; bool _isEnabled = true; if (InI.FiltersFileExist()) { _hideList = new string[] { }; foreach (var x in InI.filtersFile.ReadSections()) { if (InI.filtersFile.Read(x, "HideOnStartUp") == "true") { Array.Resize(ref _hideList, _hideList.Length + 1); _hideList[_hideList.Length - 1] = x; } } bool _found = false; if (_hideList.Length < (addF.DataContext as AddNewPanelViewModel).tags.Length) { foreach (var x in _hideList) { foreach (var y in (addF.DataContext as AddNewPanelViewModel).tags) { if (x == y) { _found = true; break; } } } } else { foreach (var x in (addF.DataContext as AddNewPanelViewModel).tags) { foreach (var y in _hideList) { if (x == y) { _found = true; break; } } } } if (_found) { _visibility = Visibility.Collapsed; _isEnabled = false; } else { _visibility = Visibility.Visible; _isEnabled = true; } } NewPanel((addF.DataContext as AddNewPanelViewModel).name, string.Join(";", (addF.DataContext as AddNewPanelViewModel).tags), (addF.DataContext as AddNewPanelViewModel).image, _visibility, _isEnabled); //_counter = (int.Parse(InI.panelsFile.Read("PanelCount", "Count")) + 1).ToString(); InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Path", (addF.DataContext as AddNewPanelViewModel).path); InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Version", (addF.DataContext as AddNewPanelViewModel).version); if ((addF.DataContext as AddNewPanelViewModel).updateDate.ToShortDateString() != "1/1/0001") { InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Update", (addF.DataContext as AddNewPanelViewModel).updateDate.ToShortDateString()); } else { InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Update", "Unknown"); } InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Site", (addF.DataContext as AddNewPanelViewModel).site); //InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Completed", (addF.DataContext as AddNewPanelViewModel).completed.ToString()); InI.panelsFile.Write((addF.DataContext as AddNewPanelViewModel).name, "Tags", string.Join(";", (addF.DataContext as AddNewPanelViewModel).tags)); if ((addF.DataContext as AddNewPanelViewModel).image != null) { CreateNewImage(null, (addF.DataContext as AddNewPanelViewModel).name, (addF.DataContext as AddNewPanelViewModel).image); } } }