Beispiel #1
0
		public static void Main(string[] args) {

			var client = new ClientUI("http://localhost:8080");

			client.caUpdated += (p,c) => {
					var sb = new System.Text.StringBuilder();
					foreach( var kv in p) {
						sb.AppendLine(kv.Key + ": " + kv.Value);
					}
					sb.Append(p.Count);
					Console.WriteLine(sb);
					client.pullChanges();
				};

			client.caError += (e, m) => {Console.WriteLine(m);};

			client.loadCA(args[0]);
			client.loadState(args[1]);

			client.start();

			Console.ReadLine();

			client.stop();

			client.saveState(args[2]);

			client.shutdown();

		}
		/**
		 * Initialize a new MainWindow. We establish a connection to the clientUI and connect a bunch of events.
		 * Also initialize the components such as the bitmap
		 **/
		public MainWindow() {
			InitializeComponent();
			clientui = new ClientUI("net.tcp://localhost:8080");
			bitmap = new WriteableBitmap(500, 500, 96, 96, PixelFormats.Bgr32, null);
			caTransition(State.UnInited);
			clientui.caTransition += caTransition;
			clientui.caError += (t, m) => {
				this.Dispatcher.BeginInvoke(new Action(() => {
					MessageBox.Show(m, t.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
				}));
			};
			clientui.caUpdated += updateUI;
			clientui.caCleared += clearUI;
			clientui.caCleared += listBox_setup;
			clientui.caColorChange += colorChange;
			clientui.caColorChange += listBox_update;
			zoomSlider.ValueChanged += zoomSlider_ValueChanged;
			caImage.Source = bitmap;
			caImage.RenderTransform = new ScaleTransform();
			hScroll.Opacity = 0;
			vScroll.Opacity = 0;

			state = new CreateCAState();
		}