public ContactList() { InitializeComponent(); VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; myHost.Control.Controls.Add(scrollHost); myHost.AutoScroll = true; scrollHost.Control.Controls.Add(myItemsControl); myItemsControl.ContentPresenter = typeof(ContactPresenter); myItemsControl.Control = new StackPanel(); OutlookSession session = new OutlookSession(); foreach (Contact contact in session.Contacts.Items) { myItemsControl.Items.Add(contact); } }
public HelloWorld() { InitializeComponent(); // myHost is a Control that provides a transition from System.Windows.Forms to WindowlessControls. // myHost.Control is the WindowlessControls.WindowlessControl that is "hosted" in the Windows.Windows.Forms.Control. // put all the forms contents into a scrollHost, which will resize arbitrarily to fit its contents VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; myHost.Control.Controls.Add(scrollHost); // enable auto scrolling on myHost so if the contents (scrollHost) are too big, scroll bars appear myHost.AutoScroll = true; // hello world! WindowlessLabel hello1 = new WindowlessLabel("Hello World!"); stack.Controls.Add(hello1); // center this label and use a different font Font center = new Font(FontFamily.GenericSerif, 20, FontStyle.Regular); WindowlessLabel hello2 = new WindowlessLabel("Centered!", center); hello2.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Center; stack.Controls.Add(hello2); // right align this control WindowlessLabel right = new WindowlessLabel("Right Aligned!"); right.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Right; stack.Controls.Add(right); // show that controls support margins WindowlessLabel margin = new WindowlessLabel("Margin!"); margin.Margin = new Thickness(20, 20, 20, 20); // margins for the left, top, right, and bottom stack.Controls.Add(margin); // nest controls within another control and center the parent StackPanel child = new StackPanel(); child.Controls.Add(new WindowlessLabel("Nested")); child.Controls.Add(new WindowlessLabel("Controls")); child.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Center; stack.Controls.Add(child); // create a clickable hyperlink HyperlinkButton button = new HyperlinkButton("Click Me!"); child.Controls.Add(button); button.WindowlessClick += (s, e) => { MessageBox.Show("Hello!"); }; // when the hyperlink is clicked, the event will bubble up to every host in the hierarchy // watch for the event and handle it myHost.WindowlessClick += (s, e) => { if (s != myHost) { MessageBox.Show("A click event just bubbled up to me from " + s.GetType().ToString() + "!"); } }; // draw a centered image PlatformBitmap bitmap = PlatformBitmap.FromResource("mybrainhurts.jpg"); WindowlessImage image = new WindowlessImage(bitmap); image.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Center; stack.Controls.Add(image); }
public MainForm() { m_Logger = new Logger(); m_Logger.LogFilePath = Path.Combine(EnvironmentEx.CallingAssemblyDirectory, "TSA.txt"); m_DevicePowered = false; DeviceManagement.ACPowerApplied += DeviceManagement_ACPowerApplied; DeviceManagement.ACPowerRemoved += DeviceManagement_ACPowerRemoved; ResourceManager.Instance.Culture = new CultureInfo("en_US"); InitializeComponent(); //m_SystemState = new SystemState(SystemProperty.PhoneRingerOff); //m_SystemState.Changed += SystemState_Changed; m_ItemsControl = new ItemsControl(); VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; WindowlessHost.Control.Controls.Add(scrollHost); WindowlessHost.AutoScroll = true; scrollHost.Control.Controls.Add(m_ItemsControl); m_ItemsControl.ContentPresenter = typeof(StationPresenter); m_ItemsControl.Control = new StackPanel(); m_Options = new Options(); m_Options.UseGps += chkUseGps_Click; m_Options.RouteChanged += Options_RouteChanged; m_Options.DebugChanged += Options_DebugChanged; m_PowerRequirements = IntPtr.Zero; m_SMSSent = false; m_LocationServiceStarted = false; bool _Error = false; m_UpdateDataHandler = UpdateData; //m_Vibrate = new Vibrate(); //m_Timer = new Timer(); //m_Timer.Interval = GetInterval(); //m_Timer.Tick += Timer_Tick; try { m_SMSSender = new SMSSender(); m_SMSSender.SMSCompleted += SMSSender_SMSCompleted; } catch (Exception e) { _Error = true; MessageBox.Show(e.Message); } if (!_Error) { //m_Timer.Enabled = chkAlwaysOn.Checked; LoadStationList(false); if (Options.AutoStartLocationService && !m_LocationServiceStarted) { StartLocationService(); m_LocationServiceStarted = true; } menuItem1.Text = (m_LocationServiceStarted ? "Stop" : "Start"); txtStatus.Text = string.Format("{0} Running on Emulator", !NativeMethods.IsEmulator() ? "Not" : string.Empty).Trim(); txtStatus.Visible = Options.DebugOn; } else { Close(); Application.Exit(); } }
public ImageGallery() { InitializeComponent(); VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; myHost.Control.Controls.Add(scrollHost); myHost.AutoScroll = true; // we need to layer two controls on top of another: a background, with another panel containing more controls OverlayPanel overlay = new OverlayPanel(); stack.Controls.Add(overlay); // set up the background bitmap and control PlatformBitmap backgroundBitmap = PlatformBitmap.FromResource("Wallpaper.jpg"); WindowlessImage background = new WindowlessImage(backgroundBitmap); background.Stretch = Stretch.Uniform; overlay.Controls.Add(background); // set up the foreground StackPanel foreground = new StackPanel(); overlay.Controls.Add(foreground); // set up the ItemsControl which will hold the images myItemsControl.BackColor = Color.Transparent; // the images will be contained in a wrap panel myItemsControl.Control = new WrapPanel(); // this tells the ItemsControl what is used to represent the content items myItemsControl.ContentPresenter = typeof(ImageResourcePresenter); foreground.Controls.Add(myItemsControl); // let's get a list of image resources Assembly ass = Assembly.GetCallingAssembly(); string[] names = ass.GetManifestResourceNames(); foreach (string name in names) { foreach (string extension in imageExtensions) { if (name.EndsWith(extension, StringComparison.CurrentCultureIgnoreCase)) { myItemsControl.Items.Add(name); break; } } } // now let's search the file system for images foreach (string name in Directory.GetFiles("\\My Documents\\My Pictures")) { foreach (string extension in imageExtensions) { if (name.EndsWith(extension, StringComparison.CurrentCultureIgnoreCase)) { myItemsControl.Items.Add(name); break; } } } }
public MainForm() { m_Logger = new Logger(); m_Logger.LogFilePath = Path.Combine(EnvironmentEx.CallingAssemblyDirectory, "TSA.txt"); m_DevicePowered = false; DeviceManagement.ACPowerApplied += DeviceManagement_ACPowerApplied; DeviceManagement.ACPowerRemoved += DeviceManagement_ACPowerRemoved; ResourceManager.Instance.Culture = new CultureInfo("en_US"); InitializeComponent(); //m_SystemState = new SystemState(SystemProperty.PhoneRingerOff); //m_SystemState.Changed += SystemState_Changed; m_ItemsControl = new ItemsControl(); VerticalStackPanelHost scrollHost = new VerticalStackPanelHost(); StackPanel stack = scrollHost.Control; stack.HorizontalAlignment = WindowlessControls.HorizontalAlignment.Stretch; WindowlessHost.Control.Controls.Add(scrollHost); WindowlessHost.AutoScroll = true; scrollHost.Control.Controls.Add(m_ItemsControl); m_ItemsControl.ContentPresenter = typeof(StationPresenter); m_ItemsControl.Control = new StackPanel(); m_Options = new Options(); m_Options.UseGps += chkUseGps_Click; m_Options.RouteChanged += Options_RouteChanged; m_Options.DebugChanged += Options_DebugChanged; m_PowerRequirements = IntPtr.Zero; m_SMSSent = false; m_LocationServiceStarted = false; bool _Error = false; m_UpdateDataHandler = UpdateData; //m_Vibrate = new Vibrate(); //m_Timer = new Timer(); //m_Timer.Interval = GetInterval(); //m_Timer.Tick += Timer_Tick; try { m_SMSSender = new SMSSender(); m_SMSSender.SMSCompleted += SMSSender_SMSCompleted; } catch (Exception e) { _Error = true; MessageBox.Show(e.Message); } if (!_Error) { //m_Timer.Enabled = chkAlwaysOn.Checked; LoadStationList(false); if (Options.AutoStartLocationService && !m_LocationServiceStarted) { StartLocationService(); m_LocationServiceStarted = true; } menuItem1.Text = (m_LocationServiceStarted ? "Stop" : "Start"); txtStatus.Text = string.Format("{0} Running on Emulator", !NativeMethods.IsEmulator() ? "Not" : string.Empty).Trim(); txtStatus.Visible = Options.DebugOn; } else { Close(); Application.Exit(); } }