Esempio n. 1
0
        public List<Container> CalculateLoadScheme(List<Container> containers,
            ObservableCollection<Vehicle> selectedVehicles, TextBox textBox, int maxTonnage)
        {
            // BtnCalculate_click
            int tempMaxTonnage;
            var widthBetweenVehicles = 1000;
            var tempPoint = new Point3D(0, 0, 0);
            textBox.Clear();
            textBox.AppendText("Протокол расчета схемы загрузки:\n");
            var tempList = RotateContainers(containers);

            foreach (var vehicle in selectedVehicles)
            {
                LocateContainers locateContainers = new LocateContainers(vehicle);

                tempMaxTonnage = maxTonnage == 0 ? vehicle.Tonnage : maxTonnage;
                tempList = locateContainers.DownloadContainers(tempList, tempMaxTonnage);
                SetFirstPoint(tempPoint,vehicle);
                tempPoint.Y = tempPoint.Y + widthBetweenVehicles + vehicle.Width;// TODO tempPoint.Z = tempPoint.Z + widthBetweenVehicles + vehicle.Width;
                PutCargoInfoInTextBox(vehicle, textBox);
                CheckOverweight(vehicle, textBox, tempMaxTonnage);
                VehicleAxisMass vehicleAxisMass = new VehicleAxisMass(vehicle, vehicle.Mass);
                PutVehAxisMassInfoInTextBox(vehicleAxisMass.AxisMassCalculate(), textBox);
            }
            PutWasteContainersInfoInTextBox(tempList, textBox);
            CheckErrors(tempList, textBox, selectedVehicles, containers);

            return tempList;
        }
Esempio n. 2
0
 public void TextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     e.Handled = false;
     System.Windows.Controls.TextBox textBox = TextBox1;
     if (e.Key == Key.Enter)
     {
         if (!Keyboard.IsKeyDown(Key.LeftShift))
         {
             textBox.MoveFocus(traversalRequest);
         }
         else
         {
             int i = textBox.CaretIndex;
             textBox.Text       = textBox.Text.Substring(0, i) + "\n" + textBox.Text.Substring(i, textBox.Text.Length - i);
             textBox.CaretIndex = i + 1;
         }
     }
     else if (e.Key == Key.Subtract)
     {
         System.Windows.Controls.TextBox box = (System.Windows.Controls.TextBox)sender;
         int caret = box.CaretIndex;
         box.Text       = box.Text.Insert(box.CaretIndex, "-");
         box.CaretIndex = caret + 1;
         e.Handled      = true;
     }
     textBox.AppendText(String.Empty);
 }
 /// <summary>
 /// Agrega texto a la salida por consola del servidor
 /// </summary>
 /// <param name="text">texto a mostrar</param>
 public static void SetText(string text)
 {
     parent.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
     {
         serverDebug.AppendText(text + Environment.NewLine);
     }));
 }
Esempio n. 4
0
    // Methods *****************
    public string arvonta(TextBox outcome)
    {
      metodi m;
      
      switch (mode)
      {
        case 0:
          m = Logics.suomi;
          break;
        case 1:
          m = Logics.viking;
          break;
        case 2:
          m = Logics.euro;
          break;
        default:
          // If mode is not defined throw exception
          throw new Exception("Error #666. Lottery mode was not defined!");
      }
      
      for(int i = 0; i < drawns; i++)
      {
        outcome.AppendText(m() + "\n");
      }

      return "Arvonta tehty :D";
    }
Esempio n. 5
0
 public void Write(string str)
 {
     box.Dispatcher.BeginInvoke((Action)(() =>
     {
         box.AppendText(str);
         box.ScrollToEnd();
     }));
 }
Esempio n. 6
0
 public override void Write(char value)
 {
     base.Write(value);
     textBox.Dispatcher.BeginInvoke(new Action(() =>
     {
         textBox.AppendText(value.ToString());
     }));
 }
Esempio n. 7
0
        private void PutVehAxisMassInfoInTextBox(List<double> axisMassList,TextBox textBox)
        {
            for (int i=0; i<axisMassList.Count;i++)
            {
                textBox.AppendText(String.Format("Нагрузка на ось{0} - {1:0.000} \n", (i + 1), axisMassList[i]));
            }

        }
Esempio n. 8
0
        private void DodajText(System.Windows.Controls.TextBox TextBox, string Text, System.Drawing.Color Color)
        {
            var StartIndex = TextBox.Text.Length;

            TextBox.AppendText(Text);
            var EndIndex = TextBox.Text.Length;

            TextBox.Select(StartIndex, EndIndex - StartIndex);
        }
 public void TextBoxUndoTest()
 {
     var textBox = new TextBox();
     Assert.IsTrue(textBox.IsUndoEnabled);
     Assert.AreEqual(100,textBox.UndoLimit);
     textBox.AppendText("1");
     Assert.IsTrue(textBox.CanUndo);
     // Assert.AreEqual(null, textBox.Text);
 }
Esempio n. 10
0
        private void UpdateStatusBox(System.Windows.Controls.TextBox statusTextBox, String Message)
        {
            var dispatchMessage = Dispatcher.BeginInvoke(DispatcherPriority.Send, (SendOrPostCallback) delegate
            {
                statusTextBox.AppendText(Message + "\r\n");
            }, null);

            System.Windows.Forms.Application.DoEvents();
        }
Esempio n. 11
0
        private static void ReadPort(Object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                if (!port.IsOpen)
                {
                    return;
                }

                var taux = port.ReadExisting();
                input.Append(taux);

                Application.Current.Dispatcher.Invoke((MethodInvoker)(() =>
                {
                    lock (uilocker)
                    {
                        var text = input.ToString();
                        var detected = false;
                        while (text.Contains("<"))
                        {
                            var text2 = text.Substring(0, text.IndexOf("<") + 1);
                            text = text.Substring(text2.Length);
                            input.Remove(0, text2.Length);

                            if (text2.Contains(">"))
                            {
                                text2 = text2.Substring(text2.LastIndexOf(">"));                                         //remuevo lo que halla llegado incompleto y quedo asi

                                if (text2.Contains(">STX09, "))
                                {
                                    var rfid = text2.Substring(text2.IndexOf(">STX09, ") + 8);                                             //, 8);
                                    rfid = rfid.Substring(0, rfid.IndexOf("<"));
                                    if (rfid.Length == 8)
                                    {
                                        detected = true;
                                        var cabezadetacho = RfidHexaFromBase36(rfid);
                                        textBox_.AppendText(String.Format("Rfid: {0} ({1}){2}", cabezadetacho, rfid, Environment.NewLine));
                                        textBox3_.Text = cabezadetacho;
                                    }
                                }
                            }
                        }
                        textBox2_.AppendText(taux + (detected ? " ._( Rfid detected )_." : "") + Environment.NewLine);
                        if (detected && !textBox_.IsFocused)
                        {
                            textBox_.ScrollToLine(textBox_.LineCount - 1);
                        }
                        if (!textBox2_.IsFocused)
                        {
                            textBox2_.ScrollToLine(textBox2_.LineCount - 1);
                        }
                    }
                }));
            }
            catch (TimeoutException) { }
        }
Esempio n. 12
0
 private void AppendText(TextBox tb, string text)
 {
     // Appends Rightclick-Text from the output text box (parameters)
     tb.AppendText(text);
     tb.Select(TxtbxOutputformat.Text.Length, 0);
     if (tb.ContextMenu != null)
     {
         tb.ContextMenu.IsOpen = false;
     }
 }
Esempio n. 13
0
 private void AppendText(System.Windows.Controls.TextBox tb, string text)
 {
     tb.AppendText(text);
     tb.Select(this.TxtbxOutputformat.Text.Length, 0);
     if (tb.ContextMenu == null)
     {
         return;
     }
     tb.ContextMenu.IsOpen = false;
 }
Esempio n. 14
0
 /// <summary>
 /// Appends text
 /// </summary>
 /// <param name="text">Text</param>
 public void AppendText(string text)
 {
     if (textBoxTemplated != null)
     {
         textBoxTemplated.AppendText(text);
     }
     else
     {
         textBox.AppendText(text);
     }
 }
Esempio n. 15
0
		public MyCanvas()
		{
			Width = DefaultWidth;
			Height = DefaultHeight;

			Colors.White.ToGradient(Colors.Gray, DefaultHeight / 4).Select(
				(c, i) =>
					new Rectangle
					{
						Fill = new SolidColorBrush(c),
						Width = DefaultWidth,
						Height = 4,
					}.MoveTo(0, i * 4).AttachTo(this)
			).ToArray();

			var t = new TextBox
			{
				AcceptsReturn = true,
				Text = "powered by jsc",
				BorderThickness = new Thickness(0),
				Foreground = Brushes.Black,
				Background = Brushes.White,
				IsReadOnly = true,
				Width = 300,
				Height = 300
			}.MoveTo(32, 32).AttachTo(this);

			var m = new MemoryStream();
			var w = new BinaryWriter(m);

			w.Write((byte)6);
			w.Write((short)7);
			w.Write((int)8);
			w.Write("hey Ԉ \ufffc \u00ff \u0100");

			t.AppendTextLine();

			foreach (var v in m.ToArray())
			{
				t.AppendText(v + " ");
			}

			m.Position = 0;

			var r = new BinaryReader(m);

			t.AppendTextLine();
			t.AppendTextLine("bytes: " + r.BaseStream.Length);
			t.AppendTextLine("byte " + r.ReadByte());
			t.AppendTextLine("short " + r.ReadInt16());
			t.AppendTextLine("int " + r.ReadInt32());
			t.AppendTextLine("string " + r.ReadString());
		}
        public TextBoxTraceListener(TextBox target)
        {
            Target = target;

            _sendStringAction = delegate(string message)
            {
                // No need to lock text box as this function will only
                // ever be executed from the UI thread

                Target.AppendText(message);
            };
        }
Esempio n. 17
0
 public void setReturnTextBox(TextBox textBox, string s)
 {
     if (textBox.Dispatcher.CheckAccess())
     {
         textBox.AppendText(s);
         textBox.ScrollToEnd();
     }
     else
     {
         setTextBox setText = new setTextBox(setReturnTextBox);
         Dispatcher.Invoke(setText, new object[] { textBox, s });
     }
 }
Esempio n. 18
0
 //设置pc接收数据到textbox中
 public void setReturnTextBox(TextBox textBox, string s)
 {
     //检查当前textbox中的被调用线程是否是当前与之相关联的dispather的线程
     if (textBox.Dispatcher.CheckAccess())
     {
         //将pc接收到的数据加入到textbox中
         textBox.AppendText(s);
         textBox.ScrollToEnd();
     }
     else
     {
         //将函数委托给事件处理,使用当前dispatcher 调用invoke该委托事件
         setTextBox setText = new setTextBox(setReturnTextBox);
         Dispatcher.Invoke(setText, new object[] { textBox, s });
     }
 }
        public LoggedTextBox(TextBox textBox)
        {
            string outputDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\BenchmarkApplication\";
            var df = new DirectoryInfo(outputDir);
            if (! df.Exists)
            {
                df = Directory.CreateDirectory(df.FullName);
            }

            string fileName = string.Format(df.FullName + "BenchmarkApplication{0}.log", DateTime.Now.ToFileTime());
            var logFile = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.None);
            this.streamWriter = new StreamWriter(logFile);
            this.textBox = textBox;

            this.appendText = delegate(string text)
            {
                textBox.AppendText(text);
                textBox.ScrollToEnd();
                textBox.Focus();
            };
        }
Esempio n. 20
0
 private void OutputHandler(object sender, DataReceivedEventArgs e)
 {
     log += e.Data + "\n";
     Win.Dispatcher.Invoke(() => { Tb.AppendText(e.Data + "\n"); Tb.ScrollToEnd(); });
 }
Esempio n. 21
0
 private void AppendToInfoBox(TextBox e, String appendedText)
 {
     if (this.Dispatcher.Thread == Thread.CurrentThread)
     {
         e.AppendText(appendedText);
         e.ScrollToEnd();
     }
     else
     {
         this.Dispatcher.Invoke(new SingleStringDelegate(AppendToInfoBox), e, appendedText);
     }        
 }
        public ApplicationCanvas()
        {
            r.Fill = Brushes.LightGray;
            r.AttachTo(this);
            r.MoveTo(4, 4);
            this.SizeChanged += (s, e) => r.SizeTo(this.Width - 8.0, this.Height - 8.0);

            var label1 = new TextBlock
            {
                Text = "Enter a list of names separated by commas",
            }.AttachTo(this).MoveTo(8, 8);

            var users = new TextBox
            {
                AcceptsReturn = true,
                TextWrapping = System.Windows.TextWrapping.Wrap,
                Width = 500,
                Height = 50,
                Text = "_martin, mike, mac, ken, neo, zen, jay, morpheous, trinity, Agent Smith, _psycho",
            }.AttachTo(this).MoveTo(8, 8 + 32);



            var label2 = new TextBlock
            {
                Text = "Enter a partial name to be found from the list above.",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8);

            var filter = new TextBox
            {
                Width = 500,
                Text = "psy",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16);

            var label3 = new TextBlock
            {
                Text = "Enter a partial name to make the entry special",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58);

            var filter2 = new TextBox
            {
                Width = 500,
                Text = "a",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58);



            var label4 = new TextBlock
            {
                Text = "Results",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58 + 58);

            var result = new TextBox
            {
                AcceptsReturn = true,
                TextWrapping = System.Windows.TextWrapping.Wrap,

                Background = Brushes.Transparent,
                BorderThickness = new Thickness(0),

                Width = 500,
                Height = 50,
                Text = "?",
                TextAlignment = System.Windows.TextAlignment.Right,
                IsReadOnly = true,
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58 + 58);

            Action Update =
                delegate
                {
                    var user_filter = filter.Text.Trim().ToLower();
                    var user_filter2 = filter2.Text.Trim().ToLower();

                    result.Clear();

                    var __users = users.Text.Split(',');


                    var query = from i in __users
                                where i.ToLower().Contains(user_filter)
                                let name = i.Trim()
                                let isspecial = i.ToLower().Contains(user_filter2)
                                orderby isspecial ascending, name.Length descending, name
                                select new { isspecial, length = name.Length, name };

                    foreach (var v in query)
                    {
                        var m = "match: " + v;

                        if (v.isspecial)
                            m = m.ToUpper();

                        result.AppendText(m + Environment.NewLine);
                    }
                };

            Update();

            users.TextChanged += delegate { Update(); };
            filter.TextChanged += delegate { Update(); };
            filter2.TextChanged += delegate { Update(); };
        }
Esempio n. 23
0
 public static void Write(this System.Windows.Controls.TextBox box, string text)
 {
     box.Clear();
     box.Foreground = Brushes.Black;
     box.AppendText(text);
 }
Esempio n. 24
0
 public static void WriteError(this System.Windows.Controls.TextBox box, string text)
 {
     box.Clear();
     box.Foreground = ColorCode.ERROR;
     box.AppendText(text);
 }
Esempio n. 25
0
 private void PutContainerVarianceInTextBox(List<Container> newList, List<Container> containers,
     TextBox textBox)
 {
     foreach (var c in containers)
     {
         var newList2 = newList.Where(t => t.Name == c.Name).ToList();
         if (!newList2.Any())
         {
             textBox.AppendText("Пропавший контейнер: " + c.Name + ".\n");
         }
         if (newList2.Count() > 1)
         {
             textBox.AppendText("Задублированный контейнер: " + c.Name + ".\n");
         }
     }
 }
Esempio n. 26
0
		//		Implementation not found for type import :
		// type: System.Windows.UIElement
		// method: Void set_BitmapEffect(System.Windows.Media.Effects.BitmapEffect)
		// Did you forget to add the[Script] attribute?
		//Please double check the signature!

		// 1>X:\jsc.svn\examples\actionscript\Avalon\AvalonLineTo\AvalonLineTo\Library\MyCanvas.cs(94,4,94,22): warning CS0618: 'UIElement.BitmapEffect' is obsolete: 'BitmapEffects are deprecated and no longer function.  Consider using Effects where appropriate instead.'


		public MyCanvas()
		{
			// http://msdn.microsoft.com/en-us/magazine/cc337899.aspx
            

            //var path2 = new Path
            //{
            //    //Fill = Brushes.Yellow,
            //    Data = new RectangleGeometry
            //    {
					
            //        Rect = new Rect
            //        {
            //            X = 4,
            //            Y = 4,
            //            Width = 400,
            //            Height = 300
            //        }
            //    }
            //};

		
            //this.Children.Add(path2);
			
			var LastX = 0.0;
			var LastY = 0.0;

			Action<double, double> LineTo =
				(x, y) =>
				{
					var l1 = new Line
					{
						Stroke = Brushes.Red,
						X1 = LastX,
						Y1 = LastY,
						X2 = x,
						Y2 = y
					};

					this.Children.Add(l1);

					LastX = x;
					LastY = y;
				};

		


			this.Background = Brushes.GreenYellow;
			
			var text = new TextBox();

			text.Background = Brushes.Transparent;
			text.Text = "some text";

			Canvas.SetLeft(text, 8);
			Canvas.SetTop(text, 12);

			this.Children.Add(text);


			var text2 = new TextBox();

			text2.Text = "some other text";
			
			
			
			Canvas.SetLeft(text2, 8);
			Canvas.SetTop(text2, 36);

			this.Children.Add(text2);

			text.Foreground = Brushes.Red;
			text2.Background = Brushes.GreenYellow;
			
			text.AppendText("dynamic");
			//text2.BitmapEffect = new DropShadowBitmapEffect();

			text2.Opacity = 0.8;
			text2.RenderTransform = new ScaleTransform { ScaleX = 2, ScaleY = 2 };

			text.TextChanged +=
				delegate
				{
					text2.Text = "auto: " + text.Text;
				};

			this.MouseMove +=
				(object sender, MouseEventArgs e) =>
				{
					var p = e.GetPosition(this);

					LineTo(p.X, p.Y);

					Canvas.SetLeft(text2, p.X + 32);
					Canvas.SetTop(text2, p.Y);
				};
		}
Esempio n. 27
0
        public static void Merge(PoiService mainDataService, string mainKey, PoiService secondaryDataService,
            string secKey,
            bool includeSecondaryPois,
            bool excludeNonExistentSecondaryPois,
            bool includeSecondaryColumns,
            bool overwriteDuplicateLabels, bool stopOnFirstHit, bool includeMetaData, FileLocation destination = null,
            TextBox txtMergeDebugOutput = null) {
            if (txtMergeDebugOutput != null)
                txtMergeDebugOutput.Text = "Merging files on [" + mainKey + " = " + secKey + "]";

            // Determine whether to use well-known text.
            var mainPoiType = mainDataService.PoITypes.FirstOrDefault();
            if (mainPoiType == null) {
                mainPoiType                = new PoI {
                    Name                   = "Default",
                    ContentId              = "Default",
                    Service                = mainDataService,
                    Style                  = new PoIStyle {
                        Name               = "default",
                        FillColor          = Colors.Transparent,
                        StrokeColor        = Color.FromArgb(255, 128, 128, 128),
                        CallOutOrientation = CallOutOrientation.Right,
                        FillOpacity        = 0.3,
                        TitleMode          = TitleModes.Bottom,
                        NameLabel          = "Name",
                        DrawingMode        = DrawingModes.Image,
                        StrokeWidth        = 2,
                        IconWidth          = 24,
                        IconHeight         = 24,
                        Icon               = "images/missing.png",
                        CallOutFillColor   = Colors.White,
                        CallOutForeground  = Colors.Black,
                        TapMode            = TapMode.CallOut
                    },
                    Id                     = Guid.NewGuid(),
                    DrawingMode            = DrawingModes.Image,
                    MetaInfo               = new List<MetaInfo>()
                };
                mainDataService.PoITypes.Add(mainPoiType);
            }

            if (mainPoiType != null && string.IsNullOrEmpty(mainPoiType.ContentId)) mainPoiType.ContentId = "Default";
            BaseContent secondaryPoiType = null;
            if (secondaryDataService.PoITypes != null && secondaryDataService.PoITypes.Any()) {
                secondaryPoiType = secondaryDataService.PoITypes.FirstOrDefault();
            }
            ;
            bool useWKT = mainPoiType != null && mainPoiType.Style != null && mainPoiType.Style.Name == "WKT";
            useWKT = (useWKT || secondaryPoiType != null && secondaryPoiType.Style != null) &&
                     secondaryPoiType.Style.Name == "WKT" && includeSecondaryColumns;
            if (useWKT) {
                if (mainPoiType != null) {
                    mainPoiType.ContentId = "WKT"; // We directly set the main PoI's "PoiId" to WKT.                    
                }
                mainDataService.StaticService = true; // Make sure we save the file as static.
                if (txtMergeDebugOutput != null)
                    txtMergeDebugOutput.AppendText(
                        "\nOne of the files uses well-known text; the output will be a static layer.");
            }

            // Merge the meta info. 
            if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerging meta info.");
            if (secondaryPoiType != null && secondaryPoiType.MetaInfo.Count == 0) {
                //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nSecondary file has no meta info; nothing to merge.");
            }
            if (secondaryPoiType != null && includeSecondaryColumns)
                foreach (MetaInfo secMetaInfo in secondaryPoiType.MetaInfo) {
                    string secMetaInfoLabel = secMetaInfo.Label;
                    bool doAdd = true;
                    if (secMetaInfoLabel == secKey) {
                        //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nLabel " + secMetaInfo.Label + " is the one we merge on, so we skip it.");
                        doAdd = false;
                    }
                    if (doAdd) {
                        if (mainPoiType != null) {
                            if (mainPoiType.MetaInfo.Any(mainMetaInfo => mainMetaInfo.Label == secMetaInfoLabel)) {
                                doAdd = false; // label already there.
                            }
                        }
                    }
                    if (!doAdd) continue;
                    if (mainPoiType != null)
                        mainPoiType.MetaInfo.Add(secMetaInfo);
                    //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nInserted meta-info from secondary file into main file: " + secMetaInfo.Label + ".");
                }

            // Merge the Style info. If the right file has WKT, set the drawing mode to MultiPolygon.
            // TODO For now we completely ignore some important aspects of poitypes:
            // 1. Multiple PoITypes.
            // 2. Different PoiId attributes.
            if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerging styles.");
            if ((secondaryPoiType != null && secondaryPoiType.Style != null && (mainPoiType.Style == null))) {
                // We need to overwrite, or the main does not have something yet.                
                mainPoiType.Style = secondaryPoiType.Style;
                //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nInserted style from secondary file into main file.");
            }
            else {
                //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMain file already has a style definition.");
            }
            if (useWKT) {
                mainPoiType.Style.DrawingMode = DrawingModes.MultiPolygon;
//                if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText(
//                    "\nEnsuring main file uses drawing mode 'multi polygon' given the fact that well-known text is used.");
            }

            // Remember which PoIs were found in the main as well as secondary file.
            HashSet<BaseContent> unvisitedMainPois = new HashSet<BaseContent>();
            foreach (var poI in mainDataService.PoIs) {
                unvisitedMainPois.Add(poI);
            }

            // Merge data.
            if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n\nMerging data.");
            foreach (var secPoi in secondaryDataService.PoIs) {
                if (!secPoi.Labels.ContainsKey(secKey)) {
//                    if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n" + secPoi.Id + " does not have label " + secKey +
//                                                   " and will be skipped.");
                    continue;
                }
                var mainPoiFound = false;
                //var mainPoi = mainDataService.PoIs.FirstOrDefault(p => p.Labels.ContainsKey(mainKey) 
                //    && string.Equals(p.Labels[mainKey], secPoi.Labels[secKey], StringComparison.InvariantCultureIgnoreCase));
                foreach (var mainPoi in mainDataService.PoIs.Where(mainPoi =>
                    mainPoi.Labels.ContainsKey(mainKey)
                    &&
                    string.Equals(mainPoi.Labels[mainKey], secPoi.Labels[secKey],
                        StringComparison.InvariantCultureIgnoreCase)))
                    if (mainPoi != null) {
                        mainPoiFound = true;
                        if (mainPoi.PoiType == null) {
                            mainPoi.PoiType = mainPoiType;
                            mainPoi.ContentId = mainPoiType.ContentId;
                        }
                        unvisitedMainPois.Remove(mainPoi); // We visited this PoI! :)

                        if (!includeSecondaryColumns)
                            continue; // Do not copy information from the secondary to the first.
                        //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nAdding new data to " + mainPoi.Labels[mainKey] + ".");
                        //GetShortFriendlyName(mainPoi.Name) + "." + mainKey + " = " + GetShortFriendlyName(secPoi.Name) + "." + secKey + "] = " + );

                        // Merge the labels part.
                        if (overwriteDuplicateLabels) {
                            //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nCopying label/values with overwrite: ");
                            foreach (var label in secPoi.Labels) {
                                if (label.Key != secKey) {
                                    //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + "=" + label.Value + ", ");
                                    mainPoi.Labels[label.Key] = label.Value;
                                }
                            }
                        }
                        else {
                            //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nCopying label/values without overwrite: ");
                            foreach (var label in secPoi.Labels.Where(l => l.Key != secKey)) {
                                string value;
                                if (mainPoi.Labels.TryGetValue(label.Key, out value)) {
                                    //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + " skipped (value already set to " + value + "), ");
                                    continue;
                                }
                                //if (label.Key == secKey)
                                //{
                                //    //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + " is the label on which we merge; skipped (value " + mainPoi.Labels[mainKey] + "), ");
                                //    continue;
                                //}
                                //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->Setting " + label.Key + " to " + label.Value);
                                mainPoi.Labels[label.Key] = label.Value;
                            }
                        }

                        // Also merge WKT information there may be.
                        if (useWKT) {
                            mainPoi.PoiTypeId = "WKT";
                        }
                        if (!string.IsNullOrWhiteSpace(secPoi.WktText)) {
                            if (overwriteDuplicateLabels || string.IsNullOrWhiteSpace(mainPoi.WktText)) {
                                //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nAlso merged well-known text elements.");
                                mainPoi.WktText = secPoi.WktText;
                            }
                        }

                        // Stop if needed.
                        if (!stopOnFirstHit) continue;
                        if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nStopping on first hit!");
                        break;

                        // And that's it.
                        //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n");
                    }

                if (mainPoiFound) continue;
                if (includeSecondaryPois) {
                    var copyPoI = new PoI();
                    copyPoI.FromXml(secPoi.ToXml());
                    if (useWKT) {
                        copyPoI.PoiTypeId = "WKT";
                    }
                    else {
                        copyPoI.PoiType = mainPoiType;
                        copyPoI.PoiTypeId = mainPoiType.PoiId;
                    }
                    copyPoI.Labels[mainKey] = copyPoI.Labels[secKey]; // Rename the merge label.
                    copyPoI.Labels.Remove(secKey);
                    mainDataService.PoIs.Add(copyPoI);
                    if (txtMergeDebugOutput != null)
                        txtMergeDebugOutput.AppendText("\nMain file does not have PoI with label " + mainKey +
                                                       " set to " + secPoi.Labels[secKey] +
                                                       ", including PoI from secondary file.");
                }
                else {
                    if (txtMergeDebugOutput != null)
                        txtMergeDebugOutput.AppendText("\nMain file does not have PoI with label " + mainKey +
                                                       " set to " + secPoi.Labels[secKey] +
                                                       " and will be skipped.");
                }
            }

            // Report on unvisited PoIs in main file.
            // Remove any PoIs in the main file that are not in the secondary file (if the user selected this option).
            if (txtMergeDebugOutput != null) {
                if (unvisitedMainPois.Any()) {
                    if (txtMergeDebugOutput != null)
                        txtMergeDebugOutput.AppendText(
                            "\nSome PoIs in the main file were not matched with a PoI in the secondary file.");
                    if (excludeNonExistentSecondaryPois && txtMergeDebugOutput != null)
                        txtMergeDebugOutput.AppendText(" These PoIs will be removed from the main file.");
                }
                foreach (BaseContent unvisitedMainPoi in unvisitedMainPois) {
                    if (txtMergeDebugOutput != null) {
                        string unvisitedMainPoiValue;
                        bool found = unvisitedMainPoi.Labels.TryGetValue(mainKey, out unvisitedMainPoiValue);
                        if (!found) {
                            unvisitedMainPoiValue = "UNDEFINED";
                        }
                        txtMergeDebugOutput.AppendText("\n" + unvisitedMainPoi + ", " + mainKey + " = " +
                                                       unvisitedMainPoiValue + ".");
                    }
                }
                if (excludeNonExistentSecondaryPois) {
                    // Annoyingly, calling "remove" on a ContentList throws an exception.
                    // Therefore, we construct a new list of PoIs that should be kept, instead of removing the PoIs we should remove.
                    ContentList newMainPoIs = new ContentList();
                    foreach (BaseContent poI in mainDataService.PoIs.Where(poI => !unvisitedMainPois.Contains(poI))) {
                        newMainPoIs.Add(poI);
                    }
                    mainDataService.PoIs = newMainPoIs;
                }
            }

            // We are done.
            if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerge completed!");

            if (destination == null) {
                mainDataService.SaveXml();
            }
            else {
                PoiServiceExporters.Instance.Export(mainDataService, destination, includeMetaData);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Update wallet log.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="logLines"></param>
        /// <param name="textBox"></param>
        /// <param name="scrollViewer"></param>
        private void AddLogText(string text, IList<string> logLines, TextBox textBox, ScrollViewer scrollViewer)
        {
            while (logLines.Count >= 50)
            {
                logLines.RemoveAt(0);
            }

            logLines.Add(text);

            if (logLines.Count == 1)
            {
                textBox.Text = logLines.First();
            }
            else
            {
                textBox.Text = logLines.Aggregate((l1, l2) => l1 + Environment.NewLine + l2);
                textBox.AppendText(Environment.NewLine); // Hack: make sure scroll to bottom works
                scrollViewer.ScrollToBottom();
            }
        }
Esempio n. 29
0
 private void PutCargoInfoInTextBox(Vehicle v, TextBox textBox)
 {
     textBox.AppendText("Загрузка автомобиля " + v.Name + " :\n");
     textBox.AppendText("  количество контейнеров - " + v.Count + " :\n");
     textBox.AppendText("  вес груза - " + v.Mass + " :\n");
 }
Esempio n. 30
0
 private void CheckOverweight(Vehicle vehicle, TextBox textBox, int MaxTonnage)
 {
     var p = vehicle.GetMassCenter();
     var maxTonnage = MaxTonnage*(vehicle.EmptyTonnage*vehicle.Length + 2*p.X*vehicle.Mass)/(vehicle.Length*(vehicle.EmptyTonnage + vehicle.Mass));
     if (vehicle.Mass > maxTonnage & p.X < vehicle.Length/2)
     {
         textBox.AppendText("Превышение нагрузки на переднюю ось \n");
     }
     if (vehicle.Mass > maxTonnage & p.X > vehicle.Length/2)
     {
         textBox.AppendText("Превышение нагрузки на заднюю ось \n");
     }
     if (vehicle.Mass > maxTonnage & p.X == vehicle.Length/2)
     {
         textBox.AppendText("Превышение нагрузки на все оси \n");
     }
 }
Esempio n. 31
0
 private void PutWasteContainersInfoInTextBox(List<Container> tempList, TextBox textBox)
 {
     if (tempList.Count > 0)
     {
         textBox.AppendText(tempList.Count + " контейнеров не вместилось в выбранные автомобили:\n");
         foreach (var t in tempList)
         {
             textBox.AppendText("  " + t.Name + " " + t.Vgh + " " + t.PriorityString + " приоритет " + "\n");
         }
     }
     else
     {
         textBox.AppendText("Все контейнеры успешно загружены.\n\n");
     }
 }
Esempio n. 32
0
 private void CheckIfPriorityContainerInWasteList(List<Container> tempList, TextBox textBox)
 {
     var priorityError = 0;
     foreach (var t in tempList)
     {
         if (t.Priority == 0)
         {
             priorityError++;
         }
     }
     if (priorityError > 0)
     {
         textBox.AppendText("Ошибка.Один или несколько приоритетных контейнеров не загрузились.\n");
     }
 }
Esempio n. 33
0
 //최근검색어 정보화면
 void btn_recent_Click(object sender, RoutedEventArgs e)
 {
     MainGrid.Children.Clear();
     MainGrid.Children.Add(recentSearch); //최근검색어
     recentSearch.wp.Children.Clear();
     string connStr = "Server=localhost;Database=naver;Uid=root;Pwd=111111;";
     MySqlConnection conn = new MySqlConnection(connStr);
     try
     {
         DataSet ds = new DataSet();
         //MySqlDataAdapter 클래스를 이용하여 비연결 모드로 데이타 가져오기
         string sql = "SELECT * FROM history;";
         MySqlDataAdapter adpt = new MySqlDataAdapter(sql, conn);
         adpt.Fill(ds, "history");
         if (ds.Tables.Count > 0)
         {
             foreach (DataRow r in ds.Tables[0].Rows)
             {
                 string temp_searchText = r["search_Text"].ToString();
                 string temp_searchTime = r["search_Time"].ToString();
                 TextBox text = new TextBox();
                 text.AppendText(temp_searchText + "\t" + temp_searchTime);
                 recentSearch.wp.Children.Add(text);
             }
         }
     }
     catch (Exception e2)
     {
         Console.WriteLine(e2.StackTrace);
     }
 }
Esempio n. 34
0
 void AppendText(TextBox box, string text)
 {
     box.AppendText(text);
 }
Esempio n. 35
0
        void btn_recent_Click(object sender, RoutedEventArgs e)
        {
            userControl.uc.Children.Clear();
            MainGrid.Children.Clear();
            MainGrid.Children.Add(userControl);                                            ////// conncet MySQL
            conn.Open();

            String sql = "select * from search ;";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            MySqlDataReader reader = cmd.ExecuteReader();
            while(reader.Read())
            {
                TextBox text = new TextBox();
                text.AppendText(reader["a"].ToString() + reader["time"].ToString());
                userControl.uc.Children.Add(text);
            }

            conn.Close();
        }
Esempio n. 36
0
 public static void AppendLineToTextBox(TextBox textBox, string message)
 {
     textBox.AppendText(message + Environment.NewLine);
     if (textBox.Text.Length > 12000)
     {
         string text = textBox.Text;
         text = text.Substring(text.Length - 10000, 10000);
         int index = text.IndexOf(Environment.NewLine);
         if (index != -1)
         {
             text = text.Substring(index + Environment.NewLine.Length);
         }
         textBox.Text = text;
     }
     textBox.CaretIndex = textBox.Text.Length;
     textBox.ScrollToEnd();
 }
Esempio n. 37
0
        public MyCanvas()
        {
            Width = DefaultWidth;
            Height = DefaultHeight;

            #region Gradient
            for (int i = 0; i < DefaultHeight; i += 4)
            {
                new Rectangle
                {
                    //Fill = ((uint)(0xff00007F + Convert.ToInt32(128 * i / DefaultHeight))).ToSolidColorBrush(),
                    Fill = ((uint)(0xff00007F + (int)(128 * i / DefaultHeight))).ToSolidColorBrush(),
                    Width = DefaultWidth,
                    Height = 4,
                }.MoveTo(0, i).AttachTo(this);
            }
            #endregion

            var help_idle = new Image
            {
                Source = "assets/ZipExample2/help_idle.png".ToSource()
            }.AttachTo(this);

            var help = new Image
            {
                Source = "assets/ZipExample2/help.png".ToSource()
            }.AttachTo(this);

            help.Opacity = 0;

            var img = new Image
            {
                Source = "assets/ZipExample2/jsc.png".ToSource()
            }.MoveTo(DefaultWidth - 128, DefaultHeight - 128).AttachTo(this);

            var t = new TextBox
            {
                FontSize = 32,
                Text = "archive: ",
                BorderThickness = new Thickness(0),
                Foreground = 0xffffffff.ToSolidColorBrush(),
                Background = Brushes.Transparent,
                IsReadOnly = true
            }.MoveTo(32, 32).AttachTo(this);


            var zip = "assets/ZipExample2/dude5.zip".ToZIPFile();

            t.AppendText(zip.Items.Count + " " + zip.Items.First().FileName);

            var AnimatedImage = new Image
            {
                RenderTransform = new ScaleTransform { ScaleX = 2, ScaleY = 2 }
            }.MoveTo(64, 64).AttachTo(this);

            var AnimationIndex = 0;
            var AnimationCounter = 0;

            (1000 / 8).AtInterval(
                () =>
                {
                    AnimationCounter++;

                    AnimationIndex += 8;

                    if ((AnimationCounter % (zip.Items.Count / 8)) == 0)
                        AnimationIndex++;

                    var n = zip.Items.AtModulus(AnimationIndex);



                    t.Text = "# " + n.FileName;



                    AnimatedImage.Source = n.Data.ToSource();
                }
            );

            help_idle.Opacity = 0;
            help.Opacity = 1;
            img.Opacity = 0.5;

            t.MouseEnter +=
                delegate
                {
                    help_idle.Opacity = 1;
                    help.Opacity = 0;

                    img.Opacity = 1;
                    t.Foreground = 0xffffff00.ToSolidColorBrush();
                };

            t.MouseLeave +=
                delegate
                {
                    help_idle.Opacity = 0;
                    help.Opacity = 1;

                    img.Opacity = 0.5;
                    t.Foreground = 0xffffffff.ToSolidColorBrush();
                };



        }
Esempio n. 38
0
        private void CheckContainerCount(List<Container> containers, List<Container> tempList, TextBox textBox,
            ObservableCollection<Vehicle> selectedVehicles)
        {
            var contCount = XmlHelper.ContainersCount(tempList);

            var newList = fromTempListToContList.ToContainerList(tempList);
            foreach (var v in selectedVehicles)
            {
                contCount = contCount + v.Count;
                newList.AddRange(v.VehicleToContainerList());
            }
            if (containers.Count() != contCount)
            {
                textBox.AppendText("Ошибка. Расхождение количества контейнеров: было " + containers.Count() + ", стало" +
                                   contCount + ".\n");
                PutContainerVarianceInTextBox(newList, containers, textBox);
            }
        }