Exemple #1
0
        internal VNode(MNode node, WFrameworkElement frameworkElementOfNodeForLabelOfLabel,
                       Func <MEdge, VEdge> funcFromDrawingEdgeToVEdge, Func <double> pathStrokeThicknessFunc)
        {
            PathStrokeThicknessFunc = pathStrokeThicknessFunc;
            Node = node;
            FrameworkElementOfNodeForLabel = frameworkElementOfNodeForLabelOfLabel;

            _funcFromDrawingEdgeToVEdge = funcFromDrawingEdgeToVEdge;

            CreateNodeBoundaryPath();
            if (FrameworkElementOfNodeForLabel != null)
            {
                FrameworkElementOfNodeForLabel.Tag = this; //get a backpointer to the VNode
                Common.PositionFrameworkElement(FrameworkElementOfNodeForLabel, node.GeometryNode.Center, 1);
                WPanel.SetZIndex(FrameworkElementOfNodeForLabel, WPanel.GetZIndex(BoundaryPath) + 1);
            }
            SetupSubgraphDrawing();
            Node.Attr.VisualsChanged += (a, b) => Invalidate();
            Node.IsVisibleChanged    += obj =>
            {
                foreach (var frameworkElement in FrameworkElements)
                {
                    frameworkElement.Visibility = Node.IsVisible ? WVisibility.Visible : WVisibility.Hidden;
                }
            };
        }
Exemple #2
0
 internal void CreateNodeBoundaryPath()
 {
     if (FrameworkElementOfNodeForLabel != null)
     {
         var center = Node.GeometryNode.Center;
         var margin = 2 * Node.Attr.LabelMargin;
         var bc     = NodeBoundaryCurves.GetNodeBoundaryCurve(Node,
                                                              FrameworkElementOfNodeForLabel
                                                              .Width + margin,
                                                              FrameworkElementOfNodeForLabel
                                                              .Height + margin);
         bc.Translate(center);
     }
     BoundaryPath = new WPath {
         Data = CreatePathFromNodeBoundary(), Tag = this
     };
     WPanel.SetZIndex(BoundaryPath, ZIndex);
     SetFillAndStroke();
     if (Node.Label != null)
     {
         BoundaryPath.ToolTip = Node.LabelText;
         if (FrameworkElementOfNodeForLabel != null)
         {
             FrameworkElementOfNodeForLabel.ToolTip = Node.LabelText;
         }
     }
 }
        public void UpdateUserDataField(Panel parentPanel, RadioButton baseRadioButton, MouseButtonEventHandler radioButtonMouseRightButtonUpHandler)
        {
            if (parentPanel.Children.Count > 0)
            {
                parentPanel.Children.Clear();
            }

            um.AddUserLoginFile();

            var userData = um.GetUserData();

            foreach (var(guid, userName, password, isFileExist) in userData)
            {
                var rb = new RadioButton
                {
                    Style    = baseRadioButton.Style,
                    Template = baseRadioButton.Template,
                    Tag      = guid,

                    // 画像サイズ:200*160
                    Width      = parentPanel.ActualWidth / 4,
                    Height     = parentPanel.ActualWidth / 5,
                    Background = isFileExist ? new ImageBrush(new BitmapImage(new Uri(@"Resources/folder.png", UriKind.Relative))) : new ImageBrush(new BitmapImage(new Uri(@"Resources/folder4.png", UriKind.Relative))),
                    FontSize   = parentPanel.ActualWidth / 40,
                    //Foreground = isFileExist ? Brushes.Black : Brushes.Red,
                    Foreground = !string.IsNullOrEmpty(password) ? Brushes.Black : Brushes.Red,
                    Content    = userName.Length > 12 ? userName.Substring(0, 12) + "..." : userName
                };

                rb.MouseRightButtonDown += radioButtonMouseRightButtonUpHandler;
                parentPanel.Children.Add(rb);
            }
        }
Exemple #4
0
        /// <summary>
        /// 设置容器下除排除列表外的所有的子控件的可用性,排除列表中的子控件可用性与之相反
        /// </summary>
        /// <param name="container">容器控件</param>
        /// <param name="isAvailably">是否可用,true为可用,否则为false</param>
        /// <param name="excepts">需要排除的控件列表</param>
        public static System.Windows.Controls.Panel SetChildControlAvailably(this System.Windows.Controls.Panel container, bool isAvailably, IList <System.Windows.UIElement> excepts)
        {
            if (container != null)
            {
                if (excepts == null)
                {
                    excepts = new List <System.Windows.UIElement>();
                }

                var iterator = container.Children.GetEnumerator();
                while (iterator.MoveNext())
                {
                    var element = iterator.Current;
                    if (!excepts.Contains(element))
                    {
                        SetControlAvailably(element, isAvailably);
                    }
                    else
                    {
                        SetControlAvailably(element, !isAvailably);
                    }
                }
            }
            return(container);
        }
Exemple #5
0
        void SetupCollapseSymbol()
        {
            var collapseBorderSize = GetCollapseBorderSymbolSize();

            Debug.Assert(collapseBorderSize > 0);
            _collapseButtonBorder = new WBorder
            {
                Background   = Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorInactive),
                Width        = collapseBorderSize,
                Height       = collapseBorderSize,
                CornerRadius = new WCornerRadius(collapseBorderSize / 2)
            };

            WPanel.SetZIndex(_collapseButtonBorder, WPanel.GetZIndex(BoundaryPath) + 1);


            var collapseButtonCenter = GetCollapseButtonCenter(collapseBorderSize);

            Common.PositionFrameworkElement(_collapseButtonBorder, collapseButtonCenter, 1);

            double w = collapseBorderSize * 0.4;

            _collapseSymbolPath = new WPath
            {
                Data            = CreateCollapseSymbolPath(collapseButtonCenter + new MPoint(0, -w / 2), w),
                Stroke          = _collapseSymbolPathInactive,
                StrokeThickness = 1
            };

            WPanel.SetZIndex(_collapseSymbolPath, WPanel.GetZIndex(_collapseButtonBorder) + 1);
            _topMarginRect.MouseLeftButtonDown += TopMarginRectMouseLeftButtonDown;
        }
 public void UpdateUserDataFieldSize(Panel parentPanel)
 {
     foreach (RadioButton child in parentPanel.Children)
     {
         child.Width    = parentPanel.ActualWidth / 4;
         child.Height   = parentPanel.ActualWidth / 5;
         child.FontSize = parentPanel.ActualWidth / 40;
     }
 }
        /// <summary>
        /// Initializes the animator for a WPF application.
        /// </summary>
        /// <param name="ctrl">A Control that lives for the Duration of the entire application (e.g. the main window's content panel).</param>
        public static void InitWithWPFPanel(System.Windows.Controls.Panel ctrl)
        {
            MainThreadCallerWPFControl mtcc = new MainThreadCallerWPFControl();

            ctrl.Children.Add(mtcc);

            System.Windows.Application.Current.Exit += new System.Windows.ExitEventHandler(WPFApplicationExiting);

            ManualInit();
            AnimationContext.DefaultRequiresMainThread = true;
        }
Exemple #8
0
        public HtmlRenderer(Panel container)
        {
            var host = new System.Windows.Forms.Integration.WindowsFormsHost();

            _myBrowser = new WebBrowser {
                ScriptErrorsSuppressed = true
            };
            _myBrowser.DocumentCompleted += MyBrowserDocumentCompleted;
            host.Child = _myBrowser;
            container.Children.Add(host);
        }
Exemple #9
0
 private void MiniPlayer_OnKeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key != Key.LeftShift)
     {
         return;
     }
     Panel.SetZIndex(BgProgressBar, -1);
     AllowDrag = true;
     _positionToolTip.IsOpen = false;
     BgProgressBar.ToolTip   = null;
 }
        public void UpdateUserDataFieldName(Panel parentPanel)
        {
            var userData = um.GetUserData();

            foreach (RadioButton child in parentPanel.Children)
            {
                var(_, userName, password, isFileExist) = userData.First(v => v.guid == child.Tag.ToString());
                child.Content = userName.Length > 12 ? userName.Substring(0, 12) + "..." : userName;
                //child.Foreground = isFileExist ? Brushes.Black : Brushes.Red;
                child.Foreground = !string.IsNullOrEmpty(password) ? Brushes.Black : Brushes.Red;
            }
        }
Exemple #11
0
        private void InitChart()
        {
            Brush chartBack = new SolidColorBrush(Color.FromRgb(200, 80, 45));

            Chart.Background  = chartBack;
            Chart.DataTooltip = null;
            Chart.Hoverable   = false;

            Chart.AxisX.Clear();
            Axis axis = new Axis
            {
                Title  = "X",
                Labels = Enumerable.Range(_firstPoint, _pointCount)
                         .Select(d => ((double)d / (double)_pointScale).ToString())
                         .ToList(),
                Separator = new Separator
                {
                    Visibility = Visibility.Collapsed
                }
            };

            Chart.AxisX.Add(axis);
            LineSeries s1 = new LineSeries
            {
                Title           = "Function",
                Values          = new ChartValues <ObservableValue>(),
                PointGeometry   = null,
                Fill            = new SolidColorBrush(Color.FromRgb(158, 45, 200)),
                StrokeThickness = 0,
            };
            LineSeries s2 = new LineSeries
            {
                Values          = new ChartValues <ObservableValue>(),
                PointGeometry   = null,
                Fill            = chartBack,
                StrokeThickness = 0
            };

            Panel.SetZIndex(s1, -2);
            Panel.SetZIndex(s2, -1);
            Chart.Series = new SeriesCollection
            {
                s1,
                s2,
            };
            for (int i = 0; i < _pointCount; i++)
            {
                Chart.Series[0].Values.Add(new ObservableValue(0));
                Chart.Series[1].Values.Add(new ObservableValue(0));
            }
            UpdateChart();
        }
Exemple #12
0
 public ArcMapManager(System.Windows.Controls.Panel mapContainer, System.Windows.Controls.Panel layoutContainer, System.Windows.Controls.Panel tocContainer)
 {
     this._mapContainer = mapContainer;
     this._layoutContainer = layoutContainer;
     this._tocContainer = tocContainer;
     this._mode = MapFunctionMode.None;
     this._geoProcessor = new Geoprocessor();
     this._geoProcessor.OverwriteOutput = true;
     this._symWindow = null;
     this._mapFile = "";
     this._polygonName = "";
     this._tempWorkspace = null;
     this._axLayoutCtrl = null;
     this._axTOCCtrl = null;
     this._axMapCtrl = null;
     this._mapAndLayoutSync = null;
 }
Exemple #13
0
        private void BgProgressBar_OnMouseMove(object sender, MouseEventArgs e)
        {
            if (Panel.GetZIndex(BgProgressBar) < 1)
            {
                return;
            }
            _positionToolTip.Content = PositionToolTipText;
            _positionToolTip.IsOpen  = BgProgressBar.IsMouseOver;
            if (!_positionToolTip.IsOpen)
            {
                return;
            }
            var p = MouseUtils.CorrectGetPosition();

            _positionToolTip.HorizontalOffset = p.X;
            _positionToolTip.VerticalOffset   = p.Y - 20;
        }
        /// <summary>
        /// ユーザ名を記載したスタックパネルの要素であるラジオボタンのどれかが右クリックされたらUserDataInputWindowを開く
        /// </summary>
        public void RbRightButtonDown(Panel parentPanel, string tag)
        {
            var udiw = new UserDataInputWindow(this)
            {
                Title = "データ管理 -" + tag,
                Tag   = tag,
            };

            var userName = um.GetUserNameFromGuid(tag);
            var password = um.GetUserPasswordFromGuid(tag);

            udiw.UserNameTextBox.Text     = userName;
            udiw.PasswordTextBox.Password = password;
            udiw.Closed += (s, a) => UpdateUserDataFieldName(parentPanel);

            udiw.ShowDialog();
        }
Exemple #15
0
        private void BgProgressBar_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (Panel.GetZIndex(BgProgressBar) < 1 || !PlaybackManagerInstance.IsSomethingLoaded)
            {
                return;
            }
            var p = MouseUtils.CorrectGetPosition(BgProgressBar);

            try
            {
                PlaybackManagerInstance.Position =
                    TimeSpan.FromMilliseconds(PlaybackManagerInstance.Duration.TotalMilliseconds /
                                              BgProgressBar.ActualWidth * p.X);
            }
            catch
            {
            }
        }
Exemple #16
0
        private void MiniPlayer_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.LeftShift || !IsVisible)
            {
                return;
            }
            Panel.SetZIndex(BgProgressBar, 1);
            AllowDrag = false;
            _positionToolTip.Content = PositionToolTipText;
            BgProgressBar.ToolTip    = _positionToolTip;
            var p = MouseUtils.CorrectGetPosition();

            _positionToolTip.HorizontalOffset = p.X;
            _positionToolTip.VerticalOffset   = p.Y - 20;
            if (BgProgressBar.IsMouseOver)
            {
                _positionToolTip.IsOpen = true;
            }
        }
Exemple #17
0
        void SetZIndexAndMouseInteractionsForTopMarginRect()
        {
            _topMarginRect.MouseEnter +=
                (
                    (a, b) =>
            {
                _collapseButtonBorder.Background =
                    Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorActive);
                _collapseSymbolPath.Stroke = WBrushes.Black;
            }
                );

            _topMarginRect.MouseLeave +=
                (a, b) =>
            {
                _collapseButtonBorder.Background = Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorInactive);
                _collapseSymbolPath.Stroke       = WBrushes.Silver;
            };
            WPanel.SetZIndex(_topMarginRect, int.MaxValue);
        }
        public static void Close(this System.Windows.Controls.UserControl userControl)
        {
            System.Windows.Controls.Panel oPanel = userControl.Parent as System.Windows.Controls.Panel;

            oPanel.Children.Remove(userControl);
        }
        public void SetContainer(System.Windows.Controls.Panel container)
        {
            StructuralParser parser = new StructuralParser(this);

            container.Children.Add(parser);
        }
        public StackedForm()
        {
            InitializeComponent();

            cartesianChart1.DisableAnimations = true;
            cartesianChart1.Pan = PanningOptions.X;
            cartesianChart1.Series.Add(new GLineSeries
            {
                Values          = _vm.Values1,
                StrokeThickness = 0,
                AreaLimit       = 0,
                PointGeometry   = null
            });
            cartesianChart1.Series.Add(new GLineSeries
            {
                Values          = _vm.Values2,
                StrokeThickness = 0,
                AreaLimit       = 0,
                PointGeometry   = null
            });
            cartesianChart1.Series.Add(new GLineSeries
            {
                Values          = _vm.Values3,
                StrokeThickness = 0,
                AreaLimit       = 0,
                PointGeometry   = null
            });

            //z index order
            Panel.SetZIndex((FrameworkElement)cartesianChart1.Series[0], 3);
            Panel.SetZIndex((FrameworkElement)cartesianChart1.Series[1], 2);
            Panel.SetZIndex((FrameworkElement)cartesianChart1.Series[2], 1);

            cartesianChart1.AxisX.Add(new Axis
            {
                LabelFormatter = _vm.XFormatter,
                Separator      = new Separator
                {
                    Step      = _vm.Step,
                    IsEnabled = false
                }
            });
            cartesianChart1.AxisY.Add(new Axis
            {
                MinValue       = -1,
                MaxValue       = 1,
                LabelFormatter = _vm.YFormatter,
                Separator      = new Separator
                {
                    Stroke = new SolidColorBrush(Color.FromRgb(235, 235, 235))
                }
            });

            scrollerchart.DisableAnimations = true;
            scrollerchart.ScrollMode        = ScrollMode.X;
            scrollerchart.ScrollBarFill     = new SolidColorBrush(Color.FromArgb(25, 30, 30, 30));
            scrollerchart.DataTooltip       = null;
            scrollerchart.Hoverable         = false;
            scrollerchart.Series.Add(new GLineSeries
            {
                Values        = _vm.Values3,
                Fill          = new SolidColorBrush(Color.FromRgb(215, 67, 21)),
                AreaLimit     = 0,
                PointGeometry = null
            });
            scrollerchart.AxisX.Add(new Axis
            {
                ShowLabels = false,
                Separator  = new Separator
                {
                    IsEnabled = false
                }
            });
            scrollerchart.AxisY.Add(new Axis
            {
                MinValue  = -1,
                MaxValue  = 1,
                Separator = new Separator
                {
                    Stroke = new SolidColorBrush(Color.FromRgb(235, 235, 235))
                }
            });

            //lets bind the charts

            //the assistant synchronizes both charts
            //here he are setting the initial range
            _assistant = new BindingAssistant
            {
                From = _vm.From,
                To   = _vm.To
            };

            cartesianChart1.AxisX[0].SetBinding(Axis.MinValueProperty,
                                                new System.Windows.Data.Binding {
                Path = new PropertyPath("From"), Source = _assistant, Mode = BindingMode.TwoWay
            });
            cartesianChart1.AxisX[0].SetBinding(Axis.MaxValueProperty,
                                                new System.Windows.Data.Binding {
                Path = new PropertyPath("To"), Source = _assistant, Mode = BindingMode.TwoWay
            });

            scrollerchart.Base.SetBinding(CartesianChart.ScrollHorizontalFromProperty,
                                          new System.Windows.Data.Binding {
                Path = new PropertyPath("From"), Source = _assistant, Mode = BindingMode.TwoWay
            });
            scrollerchart.Base.SetBinding(CartesianChart.ScrollHorizontalToProperty,
                                          new Binding {
                Path = new PropertyPath("To"), Source = _assistant, Mode = BindingMode.TwoWay
            });
        }
 public static void SetId(Windows.Controls.Panel panel, string id) => panel.SetValue(IdProperty, id);
        // If this function is called without Caliburn.Micro it will crash.  BigBox loads Caliburn.Micro
        // Encapsilating this logic into a function seems to keep .net happy
        // It must be some form of JIT assembly loading
        private void BigBoxLogic(ref bool handled, UInt64 GameIDNumber)
        {
            try
            {
                string[] libs = SteamToolsContext.GetGameLibraries();
                if (libs.Length > 0)
                {
                    // The ActiveView is just a small area of the UI sadly, but it has the plugin interface active
                    System.Windows.Controls.UserControl ActiveView        = (System.Windows.Controls.UserControl)(Unbroken.LaunchBox.Wpf.BigBox.App.MainViewModel.ActiveView);
                    System.Windows.Controls.Panel       ActiveViewContent = (System.Windows.Controls.Panel)(ActiveView.Content);

                    // The entire window view, sadly the plugin interface doesn't work here
                    //Unbroken.LaunchBox.Wpf.BigBox.Views.MainView MainView = (Unbroken.LaunchBox.Wpf.BigBox.Views.MainView)(Unbroken.LaunchBox.Wpf.BigBox.App.MainView);
                    Window MainView = Unbroken.LaunchBox.Wpf.BigBox.App.MainView;
                    System.Windows.Controls.Panel MainViewContent = (System.Windows.Controls.Panel)(MainView.Content);

                    GenericPluginProxyView         InstallLocationSelectorProxy = new GenericPluginProxyView();
                    SelectSteamInstallLocationView InstallLocationSelector      = new SelectSteamInstallLocationView();
                    InstallLocationSelectorProxy.Proxy = InstallLocationSelector;
                    InstallLocationSelector.SetLibraries(libs);
                    InstallLocationSelector.SetHeader("Select Steam Library");

                    ActiveViewContent.Children.Add(InstallLocationSelectorProxy);
                    MainViewContent.Children.Add(InstallLocationSelector);

                    // When the UI is hidden remove it and the proxy from the Views and let the GC delete them
                    InstallLocationSelector.IsVisibleChanged += (object sender, DependencyPropertyChangedEventArgs e) =>
                    {
                        if (InstallLocationSelector.Visibility == Visibility.Hidden)
                        {
                            if (InstallLocationSelector.Accepted)
                            {
                                int index = InstallLocationSelector.SelectedIndex();
                                if (index >= 0)
                                {
                                    try
                                    {
                                        SteamToolsContext.InstallGame(GameIDNumber, index);

                                        try
                                        {
                                            Unbroken.LaunchBox.Wpf.BigBox.ViewModels.TextGamesViewModel ActiveViewModel = Unbroken.LaunchBox.Wpf.BigBox.App.MainViewModel.ActiveViewModel as Unbroken.LaunchBox.Wpf.BigBox.ViewModels.TextGamesViewModel;
                                            if (ActiveViewModel != null)
                                            {
                                                ActiveViewModel.RefreshGame();
                                            }
                                            else
                                            {
                                                // show a popup telling the user they must maually reload the page
                                            }
                                        }
                                        catch (Exception ex5)
                                        {
                                            // show a popup telling the user they must maually reload the page
                                        }
                                    }
                                    catch
                                    {
                                        // in case of error, inform the user it failed and ask them if we should use the alternate method
                                    }
                                }
                            }
                            // I'm removing these from the end just in case they become orphans and get GCed mid way through
                            // Though I guess I could just store the important one in a local variable to play it safe
                            // And there is the wierd external scope stuff going on with this inline delegate too
                            ActiveViewContent.Children.Remove(InstallLocationSelectorProxy);
                            MainViewContent.Children.Remove(InstallLocationSelector);
                        }
                    };

                    InstallLocationSelector.Visibility = Visibility.Visible;

                    handled = true;
                }
            }
            catch { }
        }
 public static string GetId(Windows.Controls.Panel panel) => (string)panel.GetValue(IdProperty);
Exemple #24
0
        /// <summary>
        /// 异步等待
        /// </summary>
        /// <typeparam name="T">异步执行参数类型</typeparam>
        /// <typeparam name="TResult">异步执行返回值类型</typeparam>
        ///<param name="asynWaitPara">异步等待执行参数</param>
        ///<param name="containerControl">容器控件</param>
        ///<param name="asynWait">异步等待UI</param>
        public static void Wait <T, TResult>(PartAsynWaitPara <T, TResult> asynWaitPara, System.Windows.Controls.Panel containerControl, IPartAsynWait asynWait)
        {
            ParaValidate(asynWaitPara, containerControl);
            var asynExcute = _partAsynExcuteFactory.CreateExcute <T, System.Windows.Controls.Panel, TResult>();

            PartAsynUIParaProxy.SetAsynWait(asynWaitPara, asynWait);
            asynExcute.Excute(asynWaitPara, containerControl);
        }
Exemple #25
0
 public override void AddTOC(System.Windows.Controls.Panel tocContainer)
 {
     this._tocContainer = tocContainer;
     System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
     // Create an object of the legend control.
     this._axTOCCtrl = new AxTOCControl();
     this._axTOCCtrl.BeginInit();
     host.Child = this._axTOCCtrl;
     this._tocContainer.Children.Add(host);
     this._axTOCCtrl.SetBuddyControl(this._axMapCtrl);
     this._axTOCCtrl.OnMouseDown += new ITOCControlEvents_Ax_OnMouseDownEventHandler(this._axTOCCtrl_OnMouseDown);
     this._axTOCCtrl.EndInit();
 }
Exemple #26
0
 private void closeButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     System.Windows.Controls.Panel oPanel = this.Parent as System.Windows.Controls.Panel;
     oPanel.Children.Remove(this);
 }
Exemple #27
0
        internal DirectX9Renderer(FrameFactory owner, IXwtRender xwt, Canvas widget, System.Windows.FrameworkElement window, System.Windows.Window main, IRenderOwner renderer, FPS fps, size videosize)
        {
            this.owner      = owner;
            this.xwt        = xwt;
            this.widget     = widget;
            this.window     = window as System.Windows.Controls.Panel;
            this.mainwindow = main;
            this.videosize  = videosize;
            this.renderer   = renderer;

            var w = System.Windows.Window.GetWindow(this.mainwindow);
            var h = new WindowInteropHelper(w);

            this.hwnd = h.Handle;

            /*    mainwindow.Measure(new System.Windows.Size(double.PositiveInfinity, double.PositiveInfinity));
             *  mainwindow.Arrange(new Rect(0, 0, mainwindow.Width, mainwindow.Height));
             *
             *  this.window.Arrange(ew Rect(0, 0, this.window.ActualWidth, this.window.ActualHeight));*/



            //window..CompositionTarget

            //    OpenTKRenderer.usecnt = 1;            //  this.ctlhandle = this.ctl.Handle;
            this.viewsize = new size(Convert.ToInt32(window.ActualWidth), Convert.ToInt32(window.ActualHeight));

            this.window.SizeChanged += Ctl_SizeChanged;

            xwt.CreateForWidgetContext(this, renderer, widget);

            this.opentk = this.owner.opentk.Open(this.owner.opentkxwt, widget, renderer, fps, videosize);

            this.thread = new WorkerThread();
            this.thread.Do(() =>
            {
                //     System.Drawing.Rectangle r = new System.Drawing.Rectangle(System.Drawing.Point.Empty, this.viewsize);// Win32Helper.GetClientRect(ctlhandle);

                //     this.lastsize = new System.Drawing.Size(r.Width, r.Height);

                this.pp = new PresentParameters(this.videosize.width, this.videosize.height);
                pp.DeviceWindowHandle     = this.hwnd;
                pp.EnableAutoDepthStencil = true;
                pp.SwapEffect             = SwapEffect.Copy;
                pp.PresentationInterval   = PresentInterval.Immediate;

                try
                {
                    /*       this.direct3D = new Direct3DEx();
                     *     this.isex = true;
                     *     this.device = new DeviceEx(this.direct3D as Direct3DEx, 0, DeviceType.Hardware, this.hwnd, CreateFlags.Multithreaded | CreateFlags.HardwareVertexProcessing, pp);*/
                }
                catch
                {
                    if (this.direct3D != null)
                    {
                        throw;
                    }
                }
                if (this.direct3D == null)
                {
                    this.direct3D = new Direct3D();
                    this.device   = new Device(this.direct3D, 0, DeviceType.Hardware, this.hwnd, CreateFlags.Multithreaded | CreateFlags.HardwareVertexProcessing, pp);
                }
                this.depthtexture = new Texture(this.device, 4096, 4096, 1, Usage.DepthStencil, Format.D24S8, Pool.Default);
                this.depthsurface = this.depthtexture.GetSurfaceLevel(0);
                this.olddepth     = this.device.DepthStencilSurface;
                this.device.DepthStencilSurface = this.depthsurface;

                //       this.lastsize = r.Size;

                // Compiles the effect
                this.presenteffect = _LoadEffect("render");// Effect.FromFile(device, "render.fx", ShaderFlags.None);
                this.technique     = presenteffect.GetTechnique(0);
                this.effect2       = _LoadEffect("render2");
                this.technique2    = effect2.GetTechnique(0);
                this.effect3       = _LoadEffect("render3");


                // Get the technique

                // Prepare matrices

                // Creates and sets the Vertex Declaration
                this.vertexDecl2 = new VertexDeclaration(device, vertexElems2);
                //    device.SetStreamSource(0, vertices2, 0, Utilities.SizeOf<vertex>());
                //      device.VertexDeclaration = vertexDecl2;

                this.vertices2 = new VertexBuffer(device, Utilities.SizeOf <vertex>() * 6, Usage.WriteOnly, VertexFormat.None, isex ? Pool.Default : Pool.Managed);
                vertices2.Lock(0, 0, LockFlags.None).WriteRange(this.initdata);
                vertices2.Unlock();

                this.indices = new IndexBuffer(device, sizeof(int) * initdata2.Length, Usage.WriteOnly, isex ? Pool.Default : Pool.Managed, false);
                this.indices.Lock(0, 0, LockFlags.None).WriteRange(this.initdata2);
                this.indices.Unlock();

                this.frame = new VideoFrame(this);
                this.frame.Set(opentk.AlphaFormat);
            });

            this._layer = new layer(this);
            this._layer?.rec.Arrange(new Rect(0, 0, this.window.ActualWidth, this.window.ActualHeight));

            this.window.Children.Add((FrameworkElement)_layer);

            //this.initdone.Set();
        }
Exemple #28
0
 public void AddLayout(System.Windows.Controls.Panel layoutContainer)
 {
     this._layoutContainer = layoutContainer;
     System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
     // Create an object of the legend control.
     this._axLayoutCtrl = new AxPageLayoutControl();
     this._axLayoutCtrl.BeginInit();
     host.Child = this._axLayoutCtrl;
     this._layoutContainer.Children.Add(host);
     this._axLayoutCtrl.EndInit();
 }
Exemple #29
0
 /// <summary>
 /// 设置容器下所有的子控件的可用性
 /// </summary>
 /// <param name="container">容器控件</param>
 /// <param name="isAvailably">是否可用,true为可用,否则为false</param>
 public static System.Windows.Controls.Panel SetChildControlAvailably(this System.Windows.Controls.Panel container, bool isAvailably)
 {
     return(container.SetChildControlAvailably(isAvailably, null));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="container">The UIElement that will hold the selection rectangle.</param>
        /// <param name="location">The position of the upper left corner of the selection rectangle.</param>
        /// <param name="zoomFactor">provide the zoom factor value but it is not taken into calculations yet</param>
        public SelectionRectangle(System.Windows.Controls.Panel container, System.Windows.Point location, double zoomFactor)
        {
            t_handles = new SelectionHandle[4];

            t_container          = container;
            t_selection          = new System.Windows.Shapes.Rectangle();
            t_createDragPosition = new System.Windows.Point(location.X, location.Y);

            // TODO : add a second rectangle with white stroke so the overall selection can be seen on any back image color
            // or use a two-color stroke
            t_selection.Stroke          = System.Windows.Media.Brushes.Black;
            t_selection.StrokeThickness = 1d;
            t_selection.Fill            = System.Windows.Media.Brushes.Transparent;
            t_selection.Width           = 5;
            t_selection.Height          = 5;

            t_selection.HorizontalAlignment = HorizontalAlignment.Left;
            t_selection.VerticalAlignment   = VerticalAlignment.Top;

            SelectionLocationLeft = location.X;
            SelectionLocationTop  = location.Y;

            t_selectionTrueSize = new Rect(new System.Windows.Point(location.X / zoomFactor, location.Y / zoomFactor), new System.Windows.Size(t_selection.Width / zoomFactor, t_selection.Height / zoomFactor));
            t_zoomFactor        = zoomFactor;

            t_selection.MouseDown  += Selection_MouseDown; // also manages the double click event, see https://stackoverflow.com/questions/1631906/distinguish-between-mouse-doubleclick-and-mouse-click-in-wpf
            t_selection.MouseMove  += Selection_MouseMove;
            t_selection.MouseLeave += T_selection_MouseLeave;
            t_selection.MouseUp    += Selection_MouseUp;

            container.Children.Add(t_selection);

            // handle order change when rectangle is resized and either or both sizes get a negative value
            t_handles[0]       = CreateHandles(t_createDragPosition);
            t_handles[0].Order = 0;
            t_container.Children.Add(t_handles[0].Shape);

            t_handles[1]       = CreateHandles(t_createDragPosition);
            t_handles[1].Order = 1;
            t_container.Children.Add(t_handles[1].Shape);

            t_handles[2]       = CreateHandles(t_createDragPosition);
            t_handles[2].Order = 2;
            t_container.Children.Add(t_handles[2].Shape);

            t_handles[3]       = CreateHandles(t_createDragPosition);
            t_handles[3].Order = 3;
            t_container.Children.Add(t_handles[3].Shape);

            t_matrices = new double[4][, ];

            // assign the rotation angle appropriate to the default handle order
            // 0---------1
            // |         |
            // |         |
            // 3---------2

            // that is, if handle 2 is being moved, then no rotation is required, hence rotation 0
            // if handle 1 is being moved, rectangle is virtually rotated 90 so that delta calculations are same as if handle 2 being moved
            t_matrices[2] = Engine.Calc.Matrix.RotationMatrix0degrees();
            t_matrices[1] = Engine.Calc.Matrix.RotationMatrix90degrees();
            t_matrices[0] = Engine.Calc.Matrix.RotationMatrix180degrees();
            t_matrices[3] = Engine.Calc.Matrix.RotationMatrix270degrees();
        }
Exemple #31
0
 /// <summary>
 /// 异步等待
 /// </summary>
 /// <typeparam name="T">异步执行参数类型</typeparam>
 /// <typeparam name="TResult">异步执行返回值类型</typeparam>
 ///<param name="asynWaitPara">异步等待执行参数</param>
 ///<param name="containerControl">容器控件</param>
 public static void Wait <T, TResult>(PartAsynWaitPara <T, TResult> asynWaitPara, System.Windows.Controls.Panel containerControl)
 {
     Wait <T, TResult>(asynWaitPara, containerControl, null);
 }
Exemple #32
0
 public abstract void AddTOC(System.Windows.Controls.Panel tocContainer);
Exemple #33
0
        public static void Init(System.Windows.Controls.Panel parentControl, System.Windows.Threading.Dispatcher dispatcher)
        {
            if (!IsInited)
                SiteManagerCHR.Init();

            ParentControl = parentControl;
            Dispatcher = dispatcher;
        }
Exemple #34
0
 protected override DevExpress.Xpf.Core.IDropTarget CreateDropTargetCore(System.Windows.Controls.Panel panel)
 {
     return(new MyFixedNoneDropTarget(panel));
 }