コード例 #1
0
ファイル: SearchModel.cs プロジェクト: Sergey303/MVC-DZI
        public SearchControl(Reflected refled)
        {
			Reflected = refled;
            nameText = new TextBox();
            nameText.SetBinding(TextBox.TextProperty, new Binding("ItemName") { Mode = BindingMode.TwoWay, Source = Reflected});
            nameText.SelectAll();
            nameText.KeyUp += (sende1, e1) =>
            {
                if (e1.Key != Key.Enter) return;
                if (search && nameText.Text.Length >= 4)
                    SearchService(nameText.Text, Reflected.Type);
                else search = true;
            };
            IsContainsMethod = new CheckBox { Content = "Подстрока" , IsChecked=false };
            ResultsList = new StackPanel();
            Children.Add(nameText, IsContainsMethod, ResultsList);

        }
コード例 #2
0
ファイル: Mark.xaml.cs プロジェクト: Sergey303/MVC-DZI
		private void SendCreateNew(Reflected reflected)
		{
			if (reflected.ItemName != null)
				new Uri("?ask=newItem&user="******"&name=" + reflected.ItemName + "&type=" + reflected.Type, UriKind.Relative)
					.RequestString(newId =>
					{
						reflected.Id = newId;
						Send();
					});
		}
コード例 #3
0
ファイル: Mark.xaml.cs プロジェクト: Sergey303/MVC-DZI
        private StackPanel ReflectedToXaml(Reflected reflected, RoutedEventHandler onDelete)
		{
			var refledContainer = new StackPanel();
			var typeCombo = new ComboBox { Foreground = foregr };
			foreach (var type in Types.Keys)
				typeCombo.Items.Add(type);
            typeCombo.SelectedItem = Types.Values.Contains(reflected.Type) ? (Types.FirstOrDefault(keyValue => keyValue.Value == reflected.Type)).Key : Types.Keys.First();
            typeCombo.SelectionChanged += delegate { reflected.Type = Types[typeCombo.SelectedItem.ToString()]; };
			//refledContainer.Children.Add(new TextBlock { Text = "Тип: ", Foreground = foregr });
			refledContainer.Children.Add(typeCombo);
            //refledContainer.Children.Add(new TextBlock { Text = "Идентификатор Отражаемого: ", Foreground = foregr });
            //refledContainer.Children.Add(new TextBox { Foreground = foregr }
		   // .Binding(TextBox.TextProperty, new Binding("Id") { Mode = BindingMode.TwoWay, Source = reflected }));
			//refledContainer.Children.Add(delete);

			refledContainer.Children.Add(new TextBlock { Text = "Наименование(поиск по Enter) : ", Foreground = foregr });
			refledContainer.Children.Add(new SearchControl(reflected)
			{
				NameSet=ViewReflectedsList,
				NewCreate = () =>
				{
					reflected.Id = Guid.NewGuid().ToString();
					SendCreateNew(reflected);
					IsEditMenuVisible = false;
				}

			});
			var delref = new Button { Content = "открепить" };
            delref.Click += onDelete;// delegate { if (list != null)list.Items.Remove(refledContainer); Props.Reflecteds.Remove(reflected); ViewReflectedsList(); };
			refledContainer.Children.Add(delref);
			return refledContainer;
		}
コード例 #4
0
ファイル: Mark.xaml.cs プロジェクト: Sergey303/MVC-DZI
		//private void SetState(string parameter, StateSetted changedState)
		//{
		//    state = (String.IsNullOrEmpty(parameter))
		//                ? state ^ changedState
		//                : state | changedState;
		//}

        //private ComboBox linkCombo;
        //public ComboBox LinkCombo
        //{
        //    get
        //    {
        //        if (linkCombo == null)
        //        {
        //            linkCombo = new ComboBox();
        //            linkCombo.Items.Add("Http://sergey.iis.nsk.su/PA/?id=");
        //            linkCombo.SelectedIndex = 0;
        //        }
        //        return linkCombo;
        //    }
        //    set { linkCombo = value; }
        //}

		private void CreateEditMenu()
		{
			if (Props.IsCreatedEditMenu) return;
			Props.IsCreatedEditMenu = true;
			//var blue = new SolidColorBrush(Colors.Blue);			
			HidedContent.Background = new SolidColorBrush(Colors.White);
			var list = new ListBox{Margin = new Thickness(10,0,0,0)};  
			foreach (var reflected in Props.Reflecteds)
            {
            StackPanel reflecteddXaml= null;
                list.Items.Add(reflecteddXaml =
                               ReflectedToXaml(reflected,
                                               delegate
                                                   {
                                                       list.Items.Remove(reflecteddXaml);
                                                       Props.Reflecteds.Remove(reflected);
                                                       ViewReflectedsList();
                                                   }));
            }
			Button addNewReflected = new Button { Content = "Добавить отражаемое" };
			addNewReflected.Click += delegate
			{
				var newReflected = new Reflected{Type="person"};
				Props.Reflecteds.Add(newReflected);
			    StackPanel newReflecteddXaml=null;
			    list.Items.Add(newReflecteddXaml = ReflectedToXaml(newReflected, delegate
			                                                                         {
			                                                                             list.Items.Remove(newReflecteddXaml);
			                                                                             Props.Reflecteds.Remove(newReflected);
			                                                                             ViewReflectedsList();
			                                                                         }));
			};
		    HidedContent.Children.Add(
                ReflectedToXaml(Props, SendDelete),
			//	new TextBlock { Text = "Идентификатор Отношения:", Foreground = foregr },
                //new TextBlock { Foreground = foregr }
                // .Binding(TextBlock.TextProperty, new Binding("ReflectionId") { Mode = BindingMode.TwoWay }),
         
				   list, addNewReflected);
		}
コード例 #5
0
ファイル: Mark.xaml.cs プロジェクト: Sergey303/MVC-DZI
		public Mark(XElement xRef, string id, DeepZPoints owner)
			: this(owner)
		{
			Owner = owner;
			var about = xRef.Attribute("id");
            //MessageBox.Show(xRef.ToString());
			if (about != null)
			{
              //  MessageBox.Show(xRef.ToString());
				Props.ReflectionId = about.Value;
				if (marks.All(m => m.Props.ReflectionId != Props.ReflectionId))
					marks.Add(this);
			}

		    var xMainReflected = xRef.Element("reflected").Elements().FirstOrDefault();
            if (xMainReflected == null) return;
            // HtmlPage.Window.Alert(props.ReflectionId);
            var name = xMainReflected.Element("name");
            if (name != null)
            {
                Props.ItemName = name.Value;
               // MessageBox.Show(Props.ItemName);
            }
            var personId = xMainReflected.Attribute("id");
            if (personId != null)
                Props.Id = personId.Value;
           ;
           if ((Props.Type = xMainReflected.Name.ToString())=="document")
               foreach (var person in xMainReflected.Elements("reflection").Select(reflected => reflected.Elements().FirstOrDefault().Elements().FirstOrDefault()))
               {
                   if (person == null) continue;
                   var newReflected = new Reflected{Type = person.Name.ToString() };
                   name = person.Element("name");
                   // MessageBox.Show(person.ToString());
                   if (name != null)
                   {
                       newReflected.ItemName = name.Value;
                       //   MessageBox.Show(newReflected.ItemName);
                   }
                 var  SubPersonId = person.Attribute("id");
                   if (SubPersonId != null)
                       newReflected.Id = SubPersonId.Value;
                   Props.Reflecteds.Add(newReflected);
               }

		    var position = xRef.Element("position");
			if (position == null)
				xRef.Add(position = new XElement("position", new XAttribute("x", 0), new XAttribute("y", 0)));
			var xAttribute = position.Attribute("x");
			var yattribute = position.Attribute("y");
			if (xAttribute != null && yattribute != null)
			{
				var x = Convert.ToDouble(xAttribute.Value);
				var y = Convert.ToDouble(yattribute.Value);
				//Margin = new Thickness(x, y, 0, 0);
				//  Props.Origin = new Point(x / Owner.ImageScale, y / Owner.ImageScale);
				//                SetPosition(x, y);
				//props.Url = new Uri("http://sergey.iis.nsk.su/pa/?id=" + props.Id);
				Props.Origin = new Point(x, y);
			}
			var xRadius = position.Attribute("r");
			if (xRadius != null)
			{
				double r = !double.TryParse(xRadius.Value, out r) ? 0.01 : r;
			    Props.Radius = r;
				FormView = Form.Circle;
			}
			else
			{
				var xSize = position.Attribute("rect");
				if (xSize != null)
				{
					var rect = xSize.Value.Split('|');
					if (rect.Length != 2) MessageBox.Show("size of rectangle has strange value " + Props.ReflectionId);
					else
					{
						double width = double.TryParse(rect[0], out width) ? width : 0.01;
						double height = double.TryParse(rect[1], out height) ? height : 0.01;
						Props.RectangleSize = new Size(width, height);
						FormView = Form.Rect;
					}
				}
			}
			Props.ImageId = id;
			Props.IsPositionEdit = false;
			ViewReflectedsList();
		}