public string OpenWindow(string pageKey, Point position, object parameter = null)
        {
            Type page;

            lock (_pages)
            {
                if (!_pages.TryGetValue(pageKey, out page))
                {
                    throw new ArgumentException(
                              string.Format("Page not found: {0}. Did you forget to call SubWindowsService.Configure?",
                                            pageKey),
                              nameof(pageKey));
                }
            }

            var subWindow = new SubWindow
            {
                X = position.X,
                Y = position.Y
            };

            _subWindowsPanel.Children.Add(subWindow);
            subWindow.Show();
            subWindow.Loaded += (sender, e) => { subWindow.Navigate(page, parameter); };
            subWindow.Closed += SubWindow_Closed;
            _subWindows.Add(subWindow.Id, subWindow);
            return(subWindow.Id);
        }
        /// <summary>
        /// Giving a Unity-supplied window id this will return any active subwindow
        /// of this editor that is using that id.
        /// </summary>
        /// <param name="windowId">The Window id supplied from something like </param>
        /// <returns></returns>
        public SubWindow GetSubwindowFromId(int windowId)
        {
            SubWindow sub = null;

            SubWindows.TryGetValue(windowId, out sub);
            return(sub);
        }
示例#3
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     SubWindow.Top  = this.Top;
     SubWindow.Left = this.Right;
     SubWindow.Show();
     LoadSettings();
 }
示例#4
0
        private Border CreateUnit(Unit unit)
        {
            UnitCounter counter = new UnitCounter();

            //counter.lbl_unit_type.Content = unit.Symbol;
            counter.img_unit_size.Source    = unit.Symbol;
            counter.img_unit_counter.Source = Images.IconQuestionmark;
            if (unit.Color != null)
            {
                counter.border_unit.Background = ColorHandler.ColorFromRGB(unit.Color);
            }

            counter.img_unit_counter.Source = unit.IconCounter;

            string tt = unit.Name + "\n";

            if (unit.Owner != null)
            {
                tt += "Besitzer von " + unit.Owner.Name + "\n";
            }
            if (unit.Commander != null)
            {
                tt += "Unter kontrolle von " + unit.Commander.Name;
            }
            counter.border_unit.ToolTip = tt;

            Border border = (Border)SubWindow.CopyFrom(counter.border_unit);

            unit.BorderParent = border;
            border.Tag        = unit;
            border.MouseUp   += UnitCounterClick;
            return(border);
        }
        /// <summary>
        /// Creates a new 'Sub Window' that acts like a window within this editor.
        /// Useful for quick-n-dirty solutions to things like movable controls,
        /// popup windows, dropdown lists, etc...
        /// </summary>
        /// <param name="position">The editor-relative position of the window.</param>
        /// <param name="updateHandler">A user-supplied method that is called each frame
        /// that the SubWindow is active.</param>
        /// <returns></returns>
        public SubWindow ShowSubwindow(int id, Rect position, GUI.WindowFunction updateHandler, SubWindow.WindowType type, GUIStyle style = null)
        {
            if (SubWindows.ContainsKey(id))
            {
                return(SubWindows[id]);
            }
            SubWindow sub = new SubWindow();

            sub.Position = GUI.Window(id, position, updateHandler, "", style);
            if (style != null)
            {
                sub.Style = style;
            }
            else
            {
                sub.Style = Skin.window;
            }
            sub.WindowId     = id;
            sub.HandleUpdate = updateHandler;
            sub.Type         = type;
            SubWindows[id]   = sub;

            //make sure to refocus controls so that
            //any delayed text boxes resets to current text
            GUI.FocusControl("");
            GUI.FocusWindow(id);

            return(sub);
        }
        private void BtnLow_OnClick(object sender, RoutedEventArgs e)
        {
            var win = SubWindow.Create("Low Window");

            win.Show(WindowZOrder.Low);

            ShowMemorySize();
        }
        private void BtnNormal_OnClick(object sender, RoutedEventArgs e)
        {
            var win = SubWindow.Create("Normal Window");

            win.Show();

            ShowMemorySize();
        }
 /// <summary>
 /// 是否包含子窗口
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 public virtual bool ContainWindow(SubWindow window)
 {
     if (m_Childs.Count == 1)
     {
         return(m_Childs[0].ContainWindow(window));
     }
     return(false);
 }
 /// <summary>
 /// 插入子窗口
 /// </summary>
 /// <param name="window"></param>
 private void InsertWindow(SubWindow window)
 {
     window.AddCloseEventListener(this.m_OnSubWindowClose);
     if (this.m_Root == null)
     {
         this.m_Root = new SubWindowNode(true, 0);
     }
     this.m_Root.AddWindow(window, 0);
 }
        private void BtnDialo_OnClick(object sender, RoutedEventArgs e)
        {
            var win = SubWindow.Create("Model Dialog");

            win.Title = "Model Dialog";
            win.Owner = this;
            win.ShowDialog();

            ShowMemorySize();
        }
示例#11
0
 /// <summary>
 /// 放置子窗口的预处理
 /// </summary>
 /// <param name="subWindow"></param>
 private void PreDropAction(SubWindow subWindow)
 {
     if (this.m_Root != null)
     {
         if (subWindow != null)
         {
             this.m_Root.RemoveWindow(subWindow); //从树中删除该子窗口
         }
     }
 }
示例#12
0
        /// <summary>
        /// Internal handler for subwindow processes. Hands control
        /// off to the user-supplied method after wrapping everything
        /// in a layout region.
        /// </summary>
        /// <param name="windowId"></param>
        void HandleSubwindow(int windowId)
        {
            SubWindow sub = GetSubwindowFromId(windowId);

            if (sub != null)
            {
                GUILayout.BeginArea(sub.Position, sub.Style);
                sub.HandleUpdate.Invoke(windowId);
                GUILayout.EndArea();
            }
        }
示例#13
0
 /// <summary>
 /// 移除
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 public virtual bool RemoveWindow(SubWindow window)
 {
     for (int i = 0; i < m_Childs.Count; i++)
     {
         bool result = m_Childs[i].RemoveWindow(window);
         if (result)
         {
             return(true);
         }
     }
     return(false);
 }
示例#14
0
    //关闭子窗口
    protected void CloseSubWindow(string name)
    {
        SubWindow subwin = null;

        if (this.subWindowsDictionary.TryGetValue(name, out subwin))
        {
            subwin.Close();
        }
        else
        {
            BDebug.LogError("不存在子窗口:" + name);
        }
    }
示例#15
0
 /// <summary>
 /// 移除窗口
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 public override bool RemoveWindow(SubWindow window)
 {
     for (int i = 0; i < m_SubWindows.Count; i++)
     {
         if (m_SubWindows[i] == window)
         {
             m_SubWindows.Remove(window);
             m_SelectSubWindow = 0;
             return(true);
         }
     }
     return(false);
 }
示例#16
0
        private void button1_Click(object sender, EventArgs e)
        {
            WindowSelectDialog wsd = new WindowSelectDialog(SubWindow.GetWindowList());

            DialogResult result = wsd.ShowDialog();

            if (result == DialogResult.OK)
            {
                textTitle.Text = wsd.SelectedItem;
            }

            wsd.Dispose();
        }
示例#17
0
    /// <summary>
    /// 打开
    /// </summary>
    /// <param name="name"></param>
    protected void OpenSubWindow(string name, WindowData windowData = null)
    {
        SubWindow subwin = null;

        if (this.subWindowsDictionary.TryGetValue(name, out subwin))
        {
            subwin.Open(windowData);
        }

        else
        {
            BDebug.LogError("不存在子窗口:" + name);
        }
    }
示例#18
0
        /// <summary>
        /// Performs some housekeeping then passes control to the user-supplied  handler.
        /// </summary>
        /// <param name="windowId"></param>
        void DoSubwindow(int windowId)
        {
            SubWindow window = GetSubwindowFromId(windowId);

            if (window.HandleUpdate != null)
            {
                window.HandleUpdate(windowId);
            }

            //for some insane reason we *have* to call this or all clicks
            //will leak onto controls behind this window. Fixed and Popup windows
            //will ignore the repositioning though.
            GUI.DragWindow();
        }
        private void AddPerson(Person person)
        {
            img_person_picture.Source = person.Image;
            lbl_person_name.Content   = person.Name;
            lbl_person_party.Content  = "Parteilos";
            if (person.Party != null)
            {
                lbl_person_party.Content = person.Party.Name;
            }
            lbl_person_age.Content            = "";
            lbl_person_this_to_him.Content    = "-";
            lbl_person_this_to_him.Foreground = Brushes.White;
            lbl_person_this_to_him.ToolTip    = "Unsere Meinung über ihn";
            lbl_person_him_to_this.Content    = "-";
            lbl_person_him_to_this.Foreground = Brushes.White;
            lbl_person_him_to_this.ToolTip    = "Seine Meinung über uns";
            if (Engine.CurrentPerson.Knows(person))
            {
                double this_to_him = Engine.CurrentPerson.GetRelationTo(person);
                lbl_person_this_to_him.Content = this_to_him;
                if (this_to_him >= 0)
                {
                    lbl_person_this_to_him.Foreground = Brushes.Green;
                    lbl_person_this_to_him.Content    = "+" + lbl_person_this_to_him.Content;
                }
                else
                {
                    lbl_person_this_to_him.Foreground = Brushes.Red;
                }
            }
            if (person.Knows(Engine.CurrentPerson))
            {
                double him_to_this = person.GetRelationTo(Engine.CurrentPerson);
                lbl_person_him_to_this.Content = him_to_this;
                if (him_to_this >= 0)
                {
                    lbl_person_him_to_this.Foreground = Brushes.Green;
                    lbl_person_him_to_this.Content    = "+" + lbl_person_him_to_this.Content;
                }
                else
                {
                    lbl_person_him_to_this.Foreground = Brushes.Red;
                }
            }
            Border border = (Border)SubWindow.CopyFrom(border_person_vorlage);

            border.MouseUp += person.PersonClick;
            panel_persons_list.Children.Add(border);
        }
        private void AddParty(Party party, string from)
        {
            lbl_party_name.Content    = party.Name;
            lbl_party_founder.Content = "<Unbekannt>";
            if (party.Founder != null)
            {
                lbl_party_founder.Content = party.Founder.Name;
            }
            lbl_party_from.Content        = from;
            lbl_party_members.Content     = party.MemberCount + " Members";
            lbl_party_politicians.Content = party.GetPossiblePersons().Length + " Politiker";
            Border border = (Border)SubWindow.CopyFrom(border_party_vorlage);

            panel_party_list.Children.Add(border);
        }
示例#21
0
        private void OnSetSubWindowActive(System.Object subwindow)
        {
            if (subwindow == null)
            {
                return;
            }
            SubWindow window = (SubWindow)subwindow;

            if (window.IsOpen)
            {
                window.Close();
            }
            else
            {
                this.InsertWindow(window);
            }
        }
示例#22
0
 public SubWindowLeaf(SubWindow window, bool isHorizontal, int depth) : base(isHorizontal, depth)
 {
     if (window != null)
     {
         window.Open();
         m_SubWindows.Add(window);
     }
     if (window == null)
     {
         m_TweenParam           = new GUITweenParam(false);
         m_TweenParam.tweenTime = 1;
     }
     else
     {
         m_TweenParam = new GUITweenParam(true);
     }
 }
示例#23
0
        /// <summary>
        /// 초기값 설정
        /// </summary>
        private void InitMainWindow()
        {
            _rHwnd = IntPtr.Zero;
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            //MainWindow View Model Data Context
            _mainWindowVM    = new MainWindowVM(this, _rHwnd);
            this.DataContext = _mainWindowVM;

            //SubWindow도 MainWindow View Model을 DataContext 설정
            _subWindow             = new SubWindow(_mainWindowVM);
            _subWindow.DataContext = _mainWindowVM;

            this.WindowStartupLocation       = WindowStartupLocation.CenterOwner;
            _subWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            _subWindow.Show();
        }
        private void BtnCover_OnClick(object sender, RoutedEventArgs e)
        {
            var win = SubWindow.Create("Cover Dialog");

            win.Show(WindowZOrder.Top);

            var coverWin = new CoverWindow
            {
                Owner      = win,
                Top        = win.Top,
                Left       = win.Left,
                Background = Brushes.Black,
                Title      = "CoverWindow" + SubWindow.GetOrder("Cover Dialog")
            };

            WindowsDockManager.SetDockBehavior(coverWin, new DockBehavior
            {
                Dock       = WinPosDockFlag.Full,
                RegionName = "CoverRegion",
                IsDockKeep = true
            });
            coverWin.SetDockOwner(win);
            coverWin.Show();
            coverWin.Hide();

            var coverWin1 = new CoverWindow
            {
                Owner      = win,
                Top        = win.Top,
                Left       = win.Left,
                Background = Brushes.Gray,
                Title      = "CoverWindow" + SubWindow.GetOrder("Cover Dialog") + "_1"
            };

            WindowsDockManager.SetDockBehavior(coverWin1, new DockBehavior
            {
                Dock       = WinPosDockFlag.Full,
                RegionName = "CoverRegion",
                IsDockKeep = true
            });
            coverWin1.SetDockOwner(win);
            coverWin1.Show();

            ShowMemorySize();
        }
示例#25
0
        /// <summary>
        /// Deactivates and destroys a previously activated SubWindow.
        /// </summary>
        /// <param name="window"></param>
        public void CloseSubwindow(SubWindow window)
        {
            if (window == null)
            {
                return;
            }
            if (SubWindows.ContainsKey(window.WindowId))
            {
                //since we might issue this command while iterating over
                //the list, we are going to add this window to a removal list
                ///that will be processed later rather than simply call List.Remove()
                SubwindowRemovalList.Add(window);

                //make sure to refocus controls so that
                //any delayed text boxes resets to current text
                GUI.FocusControl("");
            }
        }
示例#26
0
        private Border GetActionButton(string name, string color, BitmapImage icon, RoutedEventHandler handler)
        {
            Border border = (Border)SubWindow.CopyFrom(border_action_vorlage);

            border.Background = ColorHandler.ColorFromHex(color);
            Button btn = (Button)border.Child;

            btn.Click += handler;
            btn.Click += Update;
            StackPanel panel = (StackPanel)btn.Content;
            Image      img   = (Image)panel.Children[0];

            img.Source = icon;
            Label lbl = (Label)panel.Children[1];

            lbl.Content = name;
            return(border);
        }
示例#27
0
        private void DropWindow(SubWindow window, System.Action <SubWindow> preDropAction, System.Action postDropAction,
                                bool betweenChilds, int dropIndex)
        {
            if (window == null)
            {
                return;
            }
            if (preDropAction == null)
            {
                return;
            }
            if (betweenChilds)
            {
                if (preDropAction != null)
                {
                    preDropAction(window);
                    this.AddWindow(window, dropIndex);

                    postDropAction();
                }
            }
            else
            {
                if (preDropAction != null && dropIndex >= 0 && dropIndex < m_Childs.Count)
                {
                    SubWindowNode child = m_Childs[dropIndex];
                    if (child.ContainWindow(window))
                    {
                        return;
                    }
                    preDropAction(window);
                    m_Childs.RemoveAt(dropIndex);
                    SubWindowNode node = new SubWindowNode(!isHorizontal, depth + 1);
                    node.weight        = child.weight;
                    child.isHorizontal = isHorizontal;
                    child.depth        = node.depth + 1;
                    node.Insert(child, 0);

                    this.Insert(node, dropIndex);
                    node.AddWindow(window, -1);
                    postDropAction();
                }
            }
        }
示例#28
0
        public void AddDynamicWindow <T>(T drawer) where T : SubWindowCustomDrawer
        {
            if (drawer == null)
            {
                return;
            }
            string id = SubWindowObjectDrawer.GetDrawerID(drawer, true);

            if (ContainWindowID(id))
            {
                return;
            }
            SubWindow window = new SubWindow(true, drawer);

            window.isDynamic = true;
            m_SubWindowList.Add(window);
            window.Open();
            this.InsertWindow(window);
        }
示例#29
0
        private void listView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView.SelectedIndices.Count > 0)
            {
                int     idx  = listView.SelectedIndices[0];
                Setting item = Settings.Datas[idx];
                SubWindow.SetSettingData(item);

                textName.Text           = item.Name;
                textTitle.Text          = item.Title;
                numericOffsetX.Value    = item.OffsetX;
                numericOffsetY.Value    = item.OffsetY;
                numericWidth.Value      = item.Width;
                numericHeight.Value     = item.Height;
                checkDrawCursor.Checked = item.DrawCursor;
                numericInterval.Value   = item.Interval;
                checkShowFPS.Checked    = item.ShowFPS;
            }
        }
示例#30
0
        public void AddDynamicWindow(string title, string icon, EWSubWindowToolbarType toolbar, SubWindowHelpBoxType helpbox,
                                     Delegate method)
        {
            if (method == null)
            {
                return;
            }
            string id = SubWindowMethodDrawer.GetMethodID(method.Method, method.Target);

            if (ContainWindowID(id))
            {
                return;
            }
            SubWindow window = new SubWindow(title, icon, true, method.Method, method.Target, toolbar, helpbox);

            window.isDynamic = true;
            m_SubWindowList.Add(window);
            window.Open();
            this.InsertWindow(window);
        }
示例#31
0
        private void SetViewTo(SubWindow subWindow)
        {
            log.InfoFormat("switch view to {0}", subWindow.ToString());
            this.gridViewHolder.Children.Clear();
            bool thisBatchLastOne = GlobalMethods.IsLastBatch();
            ProcessState thisStepState = thisBatchLastOne ? ProcessState.Finished : ProcessState.Doing;
            switch (subWindow)
            {
                case SubWindow.Setting:
                    this.gridViewHolder.Children.Add(settingWindow);
                    ChangeWindowState(SubWindow.Setting, ProcessState.Doing);
                    break;
                case SubWindow.Measure:
                    //create or show
                    if (measureWindow == null)
                    {
                        measureWindow = new MeasureWindow();
                        measureWindow.onFinished += new MeasureWindow.Finish(measureWindow_onFinished);
                    }
                    else
                    {
                        measureWindow.Visibility = Visibility.Visible;
                    }

                    ChangeWindowState(SubWindow.ScanBarcode, thisStepState);
                    ChangeWindowState(SubWindow.Measure, ProcessState.Doing);
                    this.gridViewHolder.Children.Add(measureWindow);
                    break;
                case SubWindow.ScanBarcode:
                    //create or show
                    if (inputBarcodeWindow == null)
                    {
                        inputBarcodeWindow = new InputBarcode();
                        inputBarcodeWindow.onFinished += new InputBarcode.Finish(inputBarcodeWindow_onFinished);
                    }
                    else
                    {
                        inputBarcodeWindow.Visibility = Visibility.Visible;

                    }

                    if (GlobalVals.curBatch == 1) //first time
                    {
                        ChangeWindowState(SubWindow.Setting, ProcessState.Finished);
                        ChangeWindowState(SubWindow.ScanBarcode, ProcessState.Doing);
                    }
                    else
                    {
                        ChangeWindowState(SubWindow.ScanBarcode, thisStepState);
                        ChangeWindowState(SubWindow.Measure, ProcessState.Doing);
                    }
                    this.gridViewHolder.Children.Add(inputBarcodeWindow);
                    break;
                case SubWindow.AdjustPostion:
                    //create or show
                    if (adjustWindow == null)
                    {
                        adjustWindow = new AdjustLayout();
                        adjustWindow.onFinished += new AdjustLayout.Finish(adjustWindow_onFinished);
                    }
                    else
                    {
                        adjustWindow.Visibility = Visibility.Visible;
                    }
                    ChangeWindowState(SubWindow.Measure, thisStepState);
                    ChangeWindowState(SubWindow.AdjustPostion, ProcessState.Doing);
                    this.gridViewHolder.Children.Add(adjustWindow);
                    break;
                case SubWindow.Report:
                    if (reportWindow == null)
                    {
                        reportWindow = new ReportWindow();
                        reportWindow.onFinished += new ReportWindow.Finish(reportWindow_onFinished);
                    }
                    if (thisBatchLastOne)
                    {
                        ChangeWindowState(SubWindow.AdjustPostion, ProcessState.Finished);
                        ChangeWindowState(SubWindow.Measure, ProcessState.Finished);
                    }
                    ChangeWindowState(SubWindow.Report, ProcessState.Doing);
                    this.gridViewHolder.Children.Add(reportWindow);
                    break;
                default:
                    break;
            }
        }
示例#32
0
 /// <summary>   
 /// 设置滚动条是否显示  [email protected] qq:116149   
 /// </summary>   
 /// <param name="p_ControlHandle">句柄</param>   
 /// <param name="p_Horz">0横 1列 3全部</param>   
 /// <param name="p_Show">0隐 1显</param>   
 public static void SetScrollBar(IntPtr p_ControlHandle, int p_Horz, int p_Show)
 {
     SubWindow _SubWindow = new SubWindow(p_Horz, p_Show);
     _SubWindow.AssignHandle(p_ControlHandle);
 }
示例#33
0
        private void ChangeWindowState(SubWindow subWindow, ProcessState processState)
        {
            string windowName = "";
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add(SubWindow.Setting.ToString(), "1 设置样品");
            dict.Add(SubWindow.ScanBarcode.ToString(), "2 扫描条码");
            dict.Add(SubWindow.Measure.ToString(), "3 测量液面");
            dict.Add(SubWindow.AdjustPostion.ToString(), "4 放置载架");
            dict.Add(SubWindow.Report.ToString(), "5 报告结果");

            windowName = dict[subWindow.ToString()];

            foreach (var item in navigator.Items)
            {
                ShortNameConverter nameConverter = new ShortNameConverter();
                string sCurItem = (string)nameConverter.Convert(item, typeof(string), null, null);

                if (sCurItem == dict[subWindow.ToString()])
                {
                    ListBoxItem container = navigator.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
                    if (processState == ProcessState.Finished)
                    {
                        EnumVisual(container, Brushes.LightBlue);
                        container.IsSelected = true;
                    }
                    if (processState == ProcessState.Doing)
                    {
                        EnumVisual(container, Brushes.OrangeRed);
                    }
                    return;
                }
            }
        }