示例#1
0
        public ListBoxDemo()
        {
            InitializeComponent();

            var items = new[] { "Äpfel", "Birnen", "Pflaumen", "Bananen" };
            foreach (var item in items)
            {
                _listBox.Items.Add(item);
            }
        }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string        username = Username.Text;
            string        password = Password.Password;
            SqlConnection conn     = new SqlConnection();

            conn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\micha\Documents\GitHub\MySupervisn-Team1\MySupervisn-Team1\Users.mdf;Integrated Security=true";
            conn.Open();
            SqlCommand search = new SqlCommand();

            search.CommandText = "select User_Id,password,Classification from [Table]";
            search.Connection  = conn;
            SqlDataReader reader         = search.ExecuteReader();
            string        Classification = "";

            while (reader.Read())
            {
                if (reader[0].ToString() == username)
                {
                    username_match = true;
                    if (reader[1].ToString() == password)
                    {
                        Classification = reader[2].ToString();
                        password_match = true;
                        break;
                    }
                }
            }

            if (username_match && password_match)
            {
                switch (Classification)
                {
                case "Student":
                    break;

                case "Student Hub":

                    break;

                case "Personal Supervisor":
                    break;

                case "Director of Study":
                    break;
                }
            }
            else
            {
                MessageBox.Show("Invalid credentials", "Access Denied", MessageBoxButton.OK, MessageBoxImage.Warning);
                InitializeComponent();
            }
        }
        static TimeEntryCellContextMenuCommands ()
        {
            var bindings = new[] {
                new CommandBinding(DeleteCommand, deleteTimeEntry, canDeleteTimeEntry),
                new CommandBinding(CollapseAllDaysCommand, collapseAllDays, canCollapseAllDays),
                new CommandBinding(ExpandAllDaysCommand, expandAllDays, canExpandAllDays),
            };

            foreach (var binding in bindings)
            {
                CommandManager.RegisterClassCommandBinding(typeof(Window), binding);
            }
        }
示例#4
0
 private HalfEdgeMesh CreateUnitCubeMesh()
 {
     var vertices = new[]
         {
             new Point3D(0, 0, 0), new Point3D(1, 0, 0), new Point3D(1, 1, 0), new Point3D(0, 1, 0),
             new Point3D(0, 0, 1), new Point3D(1, 0, 1), new Point3D(1, 1, 1), new Point3D(0, 1, 1)
         };
     var mesh = new HalfEdgeMesh(vertices);
     mesh.AddFace(3, 2, 1, 0);
     mesh.AddFace(4, 5, 6, 7);
     mesh.AddFace(0, 1, 5, 4);
     mesh.AddFace(1, 2, 6, 5);
     mesh.AddFace(2, 3, 7, 6);
     mesh.AddFace(3, 0, 4, 7);
     return mesh;
 }
        public void RegisterWindowUsingAttachedProperty()
        {
            // ARRANGE
            var window = new Window();

            var expected = new[]
            {
                new ViewWrapper(window)
            };

            // ACT
            window.SetValue(DialogServiceViews.IsRegisteredProperty, true);
            
            // ASSERT
            Assert.That(DialogServiceViews.Views, Is.EqualTo(expected));
        }
 public void Triangulate_Discussion440914_ShouldBeValid()
 {
     var polygon = new[]
                       {
                           new Point(0, 0),
                           new Point(0, 1.894),
                           new Point(-2.536, 1.42),
                           new Point(-5.072, 1.42),
                           new Point(-5.072, 2.84),
                           new Point(-10.144, 2.84),
                           new Point(-10.144, 0)
                       };
     var result = CuttingEarsTriangulator.Triangulate(polygon);
     Assert.IsNotNull(result);
     Assert.AreEqual(5 * 3, result.Count);
     Assert.AreEqual(new[] { 0, 1, 2, 3, 4, 5, 6, 0, 2, 3, 5, 6, 6, 2, 3 }, result);
 }
        private void Button_OnClick_ContentCallout(object sender, RoutedEventArgs e)
        {
            // Create a reusable UI control
            if (this.panel == null)
            {
                this.panel = new StackPanel();
                this.panel.Children.Add(new TextBlock { Text = "This is a short message.", TextWrapping = TextWrapping.Wrap, });

                var checkBox = new CheckBox { Content = "Agree" };
                checkBox.Checked += (o, args) => { };
                this.panel.Children.Add(checkBox);
            }

            var buttonConfigs = new[] { new ButtonConfig("I Agree", () => { }), new ButtonConfig("I Decline") };

            this.callout.Show("Content Callout", this.panel, buttonConfigs);
        }
 public void Triangulate_Discussion440914b_ShouldBeValid()
 {
     var polygon = new[]
                       {
                           new Point(0, 0),
             new Point(0, 2.97),
             new Point(-2.389999999999997, 2.97),
             new Point(-2.389999999999997, 1.4849999999999999),
             new Point(-4.7799999999999976, 1.4849999999999999),
             new Point(-4.7799999999999976, 2.97),
             new Point(-9.5599999999999987, 2.97),
             new Point(-9.5599999999999987, 0)
                       };
     var result = CuttingEarsTriangulator.Triangulate(polygon);
     Assert.IsNotNull(result);
     Assert.AreEqual(6 * 3, result.Count);
     Assert.AreEqual(new[] { 0, 1, 2, 4, 5, 6, 0, 2, 3, 4, 6, 7, 7, 0, 3, 3, 4, 7 }, result);
 }
示例#9
0
        private void UpdateStars()
        {
            var images = new[] { ImgCommunityRating1, ImgCommunityRating2, ImgCommunityRating3, ImgCommunityRating4, ImgCommunityRating5 };

            for (int i = 0; i < 5; i++) {
                Image img = images[i];

                int starValue = (i + 1)*2;

                if (Rating < starValue - 2) {
                    img.SetResourceReference(StyleProperty, "CommunityRatingImageEmpty");
                } else if (Rating < starValue) {
                    img.SetResourceReference(StyleProperty, "CommunityRatingImageHalf");
                } else {
                    img.SetResourceReference(StyleProperty, "CommunityRatingImageFull");
                }
            }
        }
        public void RegisterFrameworkElementUsingAttachedProperty()
        {
            // ARRANGE
            var frameworkElement = new FrameworkElement();
            
            var window = new Window
            {
                Content = frameworkElement
            };

            var expected = new[]
            {
                new ViewWrapper(frameworkElement)
            };

            // ACT
            frameworkElement.SetValue(DialogServiceViews.IsRegisteredProperty, true);

            // ASSERT
            Assert.That(DialogServiceViews.Views, Is.EqualTo(expected));
        }
示例#11
0
        public static FontData FromControl(SW.Controls.Control control)
        {
            Size pixelRatios = control.GetPixelRatios ();
            var pixelSize = control.FontSize * pixelRatios.Width;

            return new FontData (control.FontFamily, pixelSize, FontSizeUnit.Pixels) {
                Style = control.FontStyle,
                Stretch = control.FontStretch,
                Weight = control.FontWeight
            };
        }
示例#12
0
        internal static double GetPointsFromPixels(SW.Controls.Control control)
        {
            Size pixelRatios = control.GetPixelRatios ();
            double dpi = (pixelRatios.Width * 96); // 96 DPI is WPF's unit

            return GetPointsFromPixels (control.FontSize, dpi);
        }
示例#13
0
        public static FontData FromControl(SW.Controls.Control control)
        {
            var pixelSize = control.FontSize;

            return new FontData (control.FontFamily, pixelSize) {
                Style = control.FontStyle,
                Stretch = control.FontStretch,
                Weight = control.FontWeight
            };
        }
示例#14
0
        protected void SetupDraw()
        {
            // Set up a quad
            var vertices = new[]
                           {
                               new Point3D(-0.5, -0.5, 0.0),
                               new Point3D( 0.5, -0.5, 0.0),
                               new Point3D( 0.5,  0.5, 0.0),
                               new Point3D(-0.5,  0.5, 0.0),
                           };

            var faces = new[]
                        {
                            0, 1, 2,
                            0, 2, 3,
                        };

            var textCoords = new[]
                             {
                                 new Point(0, 1), new Point(1, 1),
                                 new Point(1, 0), new Point(0, 0),
                             };

            Mesh = new MeshGeometry3D
            {
                Positions = new Point3DCollection(vertices),
                TriangleIndices = new Int32Collection(faces),
                TextureCoordinates = new PointCollection(textCoords),
            };
        }
示例#15
0
        private new void SetupDraw()
        {
            if (Type != TileType.Wall)
            {
                base.SetupDraw();
                return;
            }

            // Setup cube
            var vertices = new []
            {
                new Point3D(-0.5, -0.5, 0.0),
                new Point3D( 0.5, -0.5, 0.0),
                new Point3D(-0.5,  0.5, 0.0),
                new Point3D( 0.5,  0.5, 0.0),
                new Point3D(-0.5, -0.5, 1.0),
                new Point3D( 0.5, -0.5, 1.0),
                new Point3D(-0.5,  0.5, 1.0),
                new Point3D( 0.5,  0.5, 1.0)
            };

            var faces = new[]
            {
                1, 2, 3, 1, 0, 2, //back
                0, 6, 2, 6, 0, 4, //left
                7, 2, 6, 7, 3, 2, //top
                0, 5, 4, 5, 0, 1, //bottom
                7, 1, 3, 7, 5, 1, //right
                4, 7, 6, 4, 5, 7  //front
            };

            var textCoords = new[]
                             {
                                 new Point(0, 1), new Point(1, 1),
                                 new Point(1, 0), new Point(0, 0),
                             };

            Mesh = new MeshGeometry3D
            {
                Positions = new Point3DCollection(vertices),
                TriangleIndices = new Int32Collection(faces),
                TextureCoordinates = new PointCollection(textCoords),
            };
        }
        private void DoChangeMode(Window mainWindow, Instance instance)
        {
            var title = "Change App Pool Mode";
              var header = title;
              var message = "Change {0} instance's Application Pool mode".FormatWith(instance.Name);
              var options = new[]
              {
            this.GetLabel(instance, 2, false),
            this.GetLabel(instance, 2, true),
            this.GetLabel(instance, 4, false),
            this.GetLabel(instance, 4, true)
              };

              var result = WindowHelper.AskForSelection(title, header, message, options, mainWindow);
              if (result == null)
              {
            return;
              }

              if (result.Contains(LabelCurrent))
              {
            return;
              }

              instance.SetAppPoolMode(result.Contains("4.0"), result.Contains(Label32Bit));
        }
示例#17
0
        public static FontData FromControl(SW.Controls.Control control)
        {
            double size = WpfFontBackendHandler.GetPointsFromDeviceUnits (control.FontSize);

            return new FontData (control.FontFamily, size) {
                Style = control.FontStyle,
                Stretch = control.FontStretch,
                Weight = control.FontWeight
            };
        }
示例#18
0
 public static FontData FromControl(SW.Controls.Control control)
 {
     return new FontData (control.FontFamily, FontBackendHandler.GetPointsFromPixels (control)) {
         Style = control.FontStyle,
         Stretch = control.FontStretch,
         Weight = control.FontWeight
     };
 }
        public void RegisterViewThatGetsLoaded()
        {
            // ARRANGE
            var view = new Mock<FrameworkElementMock>();
            view
                .Setup(mock => mock.IsAlive)
                .Returns(true);
            
            // At time of register the view has no parent, thus is not loaded
            DialogServiceViews.Register(view.Object);

            // After register we can simulate that the view gets loaded
            view
                .Setup(mock => mock.GetOwner())
                .Returns(new Window());

            var expected = new[]
            {
                view.Object
            };

            // ACT
            view.Raise(mock => mock.Loaded += null, new RoutedEventArgs(null, view.Object));

            // ASSERT
            Assert.That(DialogServiceViews.Views, Is.EqualTo(expected));
        }
示例#20
0
 private string GetProfile()
 {
     var profiles = new[] { "silkysand", "sandbox", "ajax" };
     return profiles[mapProfile.SelectedIndex];
 }
示例#21
0
 private string GetCluster()
 {
     var clusters = new[] { "eu-n-test", "na-n-test", "au-n-test" };
     return clusters[mapCluster.SelectedIndex];
 }
示例#22
0
 public double GetDeviceIndependentPixelSize(SW.Controls.Control control)
 {
     if (Unit == FontSizeUnit.Points)
         return WpfFontBackendHandler.GetDeviceUnitsFromPoints (Size);
     else {
         Size pixelRatios = control.GetPixelRatios ();
         return Size / pixelRatios.Width;
     }
 }
示例#23
0
        public Disclaimer()
        {
            //var e1 = EnumHelper.GetEnumInformation<TestValues>();
            //var e2 = EnumHelper.GetEnumInformation<TestValues>();

            var source = new 
                { 
                    X01 = TestValues.Two,
                    X02 = OtherTestValues.Two,
                    X03 = TestValues.Two,
                    X04 = TestValues.Two,
                    X05 = TestValues.Two,
                    X06 = TestValues.Two,
                    X07 = TestValues.Two,
                    X08 = TestValues.Two,
                    X09 = TestValues.Two,
                    X10 = TestValues.Two,
                    X11 = TestValues.Two,
                    X12 = TestValues.Two,
                    X13 = TestValues.Two,
                    X14 = (System.Byte)2,
                    X15 = (System.SByte)2,
                    X16 = (System.Int16)2,
                    X17 = (System.UInt16)2,
                    X18 = (System.Int32)2,
                    X19 = (System.UInt32)2,
                    X20 = (System.Int64)2,
                    X21 = (System.UInt64)2,
                    X22 = (System.Single)2,
                    X23 = (System.Double)2,
                    X24 = (System.Decimal)2
                };

            var destination = new DestinationClass
                { 
                    X01 = OtherTestValues.Three,
                    X02 = TestValues.Three,
                    X03 = (System.Byte)3,
                    X04 = (System.SByte)3,
                    X05 = (System.Int16)3,
                    X06 = (System.UInt16)3,
                    X07 = (System.Int32)3,
                    X08 = (System.UInt32)3,
                    X09 = (System.Int64)3,
                    X10 = (System.UInt64)3,
                    X11 = (System.Single)3,
                    X12 = (System.Double)3,
                    X13 = (System.Decimal)3,
                    X14 = TestValues.Three,
                    X15 = TestValues.Three,
                    X16 = TestValues.Three,
                    X17 = TestValues.Three,
                    X18 = TestValues.Three,
                    X19 = TestValues.Three,
                    X20 = TestValues.Three,
                    X21 = TestValues.Three,
                    X22 = TestValues.Three,
                    X23 = TestValues.Three,
                    X24 = TestValues.Three,
                };

            Mapper.Map(source, destination);

            InitializeComponent();
        }
        public void RegisterLoadedView()
        {
            // ARRANGE
            var view = new Mock<FrameworkElementMock>();
            view
                .Setup(mock => mock.IsAlive)
                .Returns(true);
            view
                .Setup(mock => mock.GetOwner())
                .Returns(new Window());

            var expected = new[]
            {
                view.Object
            };
            
            // ACT
            DialogServiceViews.Register(view.Object);

            // ASSERT
            Assert.That(DialogServiceViews.Views, Is.EqualTo(expected));
        }
示例#25
0
 public double GetDeviceIndependentPixelSize(SW.Controls.Control control)
 {
     return WpfFontBackendHandler.GetDeviceUnitsFromPoints (Size);
 }
示例#26
0
		protected override SW.Size MeasureOverride (SW.Size constraint)
		{
			var s = base.MeasureOverride (constraint);
			return Backend.MeasureOverride (constraint, s);
		}